|
Posted by Rik on 02/09/07 03:08
howa <howachen@gmail.com> wrote:
>> In other words: the engine is smarter then you think.
>> --
>
> the bottom line is: the engine created dummy variables for storing two=
> copies of data, e.g.
>
>
> <?php
>
> function conv_md5( $data ) {
>
> return md5($data);
> }
>
> $data =3D "abc";
>
> echo conv_md5( $data );
> echo $data;
>
>
> ?>
>
> the engine never know we will use the variable $data later, so it
> always created allocated memory for storing the result of conv_md5(),
> only we know and can force to use return by reference.
No, it is not assigned to anything. The results are echoed and discarded=
, =
you are not using it's results again as you have not assigned it anywher=
e. =
Any variables within a function's scope are discarded on exit (unless =
declared static).
_returning_ by reference here would not change the global $data.
However, the following would make sense:
<?php
function foo(&$data){
$data =3D md5($data);
}
$bar =3D 'something';
foo($bar);
echo $bar;
?>
But that's not returning by reference, that's passing by reference.
-- =
Rik Wasmus
[Back to original message]
|