php5.1: bug or feature?
| From: | val khokhlov | Date: | Wed, 09 Feb 2005 19:07:03 +0000 |
| Subject: | php5.1: bug or feature? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-14770@lists.php.net to get a copy of this message | ||
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