php5.1: bug or feature?

php.internals

val khokhlov

21 years ago
Hello, in php5.1 i get default value of omitted parameter only the first time i call a function, all subsequent calls get the $tname set in the first call (like static!). in php5.0 $tname is always empty if omitted (as it should be) php5.1 updated from cvs on 6.02.2005 [code] function compile($sname, $tname = '') { if ($tname == '') $tname = preg_replace("!\.php$!", ".phb", $sname); echo " * source file: $sname\n * target file: $tname\n"; .... } for ($i = 1; $i < $_SERVER['argc']; $i++) { $sname = $_SERVER['argv'][$i]; compile($sname); } [output] $ ./php test.php *.php * source file: class.php * target file: class.phb
> compiled
* source file: class1.php * target file: class.phb
> compiled
* source file: class2.php * target file: class.phb
> compiled
-- Best regards, val mailto:val@vk.kiev.ua

Dmitry Stogov

21 years ago
This is the bug #30407. I will try to fix it ASAP. Thanks. Dmitry.