I'm using joomla and i have read through the API and I noticed the JFactory class having functions return a reference to the object but the examples I have gathered from the internet do not use the &
when using the functions.
Say for example the Jfactory::getSession()
which returns a reference to the global session. the documentation shows that its defined as function &getSession(params){code}
- clearly defining a reference return. however, in this example, they call it as $session = JFactory::getSession();
shouldn't it be $session =& JFactory::getSession();
?
It states here in the php documentation that there is an &
in the function and an =&
in the caller. I have also gone through C programming and if I miss things like this, there will be errors like "invalid pointer conversion" - which is not a good programming practice to tolerate.
What is the proper practice?
Additional info:
i use joomla 1.7 and i'm creating a component. i work on xampp with php 5.3.8