|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-12-12 20:52 UTC] david at 1st-affiliation dot com
Description:
------------
Hi
Since I upgrade the php version, the comportement of the function default argument as change.
Previously, when I set a parameter to "null" the function use the default value of the parameter.
Now it kept the null value, and I do not find a another way to set the default value.
See the code for more information
Reproduce code:
---------------
<?php
function eat ($what='apple') {
print 'I eat '.$what;
}
eat(null);
?>
Expected result:
----------------
I eat apple
Actual result:
--------------
I eat
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 21:00:01 2025 UTC |
/tmp/6.php is <?php function eat ($what='apple') { var_dump('I eat '.$what); } eat(null); ?> php-src_5_2> ./sapi/cli/php /tmp/6.php string(6) "I eat " php-src_5_0> ./sapi/cli/php /tmp/6.php string(6) "I eat " php-src_4_4> ./sapi/cli/php /tmp/6.php string(6) "I eat " php-src_4_3> ./sapi/cli/php /tmp/6.php string(6) "I eat " So this behaviour was introduced BEFORE 4.3. What are you talking about?