[英]Session & PHP & Joomla & Code Optimization
I'm using Joomla 2.5. 我正在使用Joomla 2.5。
1st method 第一种方法
JFactory::getSession()->set('mymessage', 'here is some message text');
2nd method 第二种方法
$session = JFactory::getSession();
$session->set('mymessage', 'here is some message text');
I use above methods(1 or 2) in my constructor. 我在构造函数中使用上面的方法(1或2)。 So I want to optimize the PHP code since it will be called multiple times during execution.
所以我想优化PHP代码,因为它会在执行期间被多次调用。 What I want to know is which method is effective and efficient?
我想知道的是哪种方法有效且高效?
Thanks 谢谢
对于每种方法(1和2),循环10次循环10 000次,并用微量时间计时并计算平均值。
First is un_named session variable call which will avoid $session
need and initialization apart from that everything is same. 首先是un_named会话变量调用,它将避免
$session
需要和初始化,除了一切都相同。 therefore first may have some efficiency over space may be in time also. 因此,首先可能在空间上有一些效率也可能及时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.