Friday, 6 March 2009

&, in Joomla api, return reference to existing object

Most of joomla api return reference, such as:

In this example, the current date and time is retrieved and output in the current default locale format.

=========================
$date =& JFactory::getDate();
echo 'Current date and time is: ' . $date->toFormat() . "\n";
If the current language is English then this will output something like
Current date and time is: 2008-11-22 18:14:08
=========================


This is because the returned object will update the existing one, while not creating new global one, except the object not created yet.
As explained here, in api.joomla.org:

=========================
getApplication (line 34)
Get a application object
Returns a reference to the global JApplication object, only creating it if it doesn't already exist.
=========================

No comments:

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter