[Phpmyadmin-devel] a PHP 5.1.2 bug?

Sebastian Mendel lists at sebastianmendel.de
Fri Jan 13 03:17:02 CET 2006


Garvin Hicking schrieb:
> Hi!
> 
>>> It surprises me that this has ever worked :)
>> it is more than logical that this should work, as = is always evaluated first!
> 
> Yes. But NOT if the function parameter expects a REFERENCE variable.

why?

function myFunction(&$param) {}

myFunction($param = true);

this gives the reference $param to the function, there is no reason why
this should not work! true is assigned to $param and than $param is
passed by reference to the function.


>> why?
>>
>> whats the difference between
>>
>> function( anotherFunction() ); function( $var = 'value' );
>>
>> ???
> 
> The difference is that
> 
> preg_replace($string, $what, resultArray());
> 
> will also not work. You can't/shouldn't pass a function as a referenced variable
> because of corruption issues that in the past of PHP have lead to problems,
> which are now being fixed up in recent PHP versions.

yes of course, but it doesn't passes a function, it passes a variable!


>> what do you think is easier to read? and why should this not work in PHP?
> 
> I consider it good coding style to not obfuscate function calls.

yes of course thats why variables names are descriptive

sort_array($my_array);

everything is clear, but

db_close(true, false);

is obfuscated!

so i would prefer

db_close($clean_cache = true, $unset_global_link_variable = false);

...

whatever, i still think this is a php bug!


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet




More information about the Developers mailing list