You are here: Re: Why Returning References can't provide speed up? « PHP Programming Language « IT news, forums, messages
Re: Why Returning References can't provide speed up?

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация