# php5.1: bug or feature?

- Thread: https://externals.io/message/14770
- Original archive: https://news-web.php.net/php.internals/14770
- Started by val khokhlov on 2005-02-09T19:07:03+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14770 — val khokhlov — 2005-02-09T19:07:03+00:00

URL: https://externals.io/message/14770#14770

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

---

## #14785 — Dmitry Stogov — 2005-02-10T08:39:45+00:00

URL: https://externals.io/message/14770#14785 · In reply to: #14770

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
> > […]
>  * source file: class1.php
>  * target file: class.phb
> > […]
>  * source file: class2.php
>  * target file: class.phb
> > […]
> 
> -- 
> Best regards,
>  val                          mailto:val@vk.kiev.ua
