[pLog-svn] PHP - Return by reference?

Oscar Renalias oscar at renalias.net
Tue Jan 30 08:48:21 EST 2007


No updates. We're not going to change it at this stage, I don't want  
to break things anymore in LT 1.2.

I don't think it's a critical issue is it?

On 30 Jan 2007, at 15:46, howard chen wrote:

> any updates?
>
> thanks.
>
>
> On 1/26/07, howard chen <howachen at gmail.com> wrote:
>> On 1/26/07, Oscar Renalias <oscar at renalias.net> wrote:
>>> We're not using those return-by-reference because of performance
>>> reasons but because of design reasons.
>>>
>>> We are just applying the Singleton pattern to make sure that  
>>> there is
>>> only one instance of the class used in the code. We want to make  
>>> sure
>>> that there is only one Config class, one Db class or one
>>> PluginManager class instead of having multiple instances of them
>>>
>>
>> if you are using static variable inside the function, there is no  
>> need
>> to use & ?
>>
>> e.g.
>>
>>
>> class Singleton {
>>
>>         var $state;
>>
>>         function getInstance() {
>>                 static $instance;
>>
>>                 if ( !isset($instance) ) {
>>                         $instance = new Singleton();
>>                 }
>>                 return $instance;
>>         }
>> }
>>
>>
>>
>>
>> $i = Singleton::getInstance();
>> $i->state = 100;
>> print $i->state;
>>
>> $j = Singleton::getInstance();
>> print $j->state;
>>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
>



More information about the pLog-svn mailing list