|
Posted by Rik on 02/08/07 18:43
howa <howachen@gmail.com> wrote:
> from PHP manual, it said:
>
>>> http://hk.php.net/manual/tw/language.references.return.php
>
> Do not use return-by-reference to increase performance, the engine is
> smart enough to optimize this on its own
>
> ------------------
>
> Why?
in case of
function foo(){
$bar =3D 'somestring';
return $bar;
}
The engine already knows it should be returned by reference, and does =
this. This would be plain silly:
function foo(){
$bar =3D 'somestring';
return &$bar;
}
As the engine already knows and does this.
Actually, a lot of assignments are treated as references untill you try =
to =
change one of the references, and only then is a copy made & assigned.
In other words: the engine is smarter then you think.
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|