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
This is the bug #30407. I will try to fix it ASAP.
Thanks. Dmitry.
-----Original Message-----
From: val khokhlov [mailto:val@vk.kiev.ua]
Sent: Wednesday, February 09, 2005 22:07
To: internals@lists.php.net
Subject: [PHP-DEV] php5.1: bug or feature?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