note 30973 deleted from language.functions by sniper
| From: | sniper@php.net | Date: | Sun, 12 Dec 2004 01:21:13 +0000 |
| Subject: | note 30973 deleted from language.functions by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-81703@lists.php.net to get a copy of this message | ||
Note Submitter: gayard at ig dot com dot br
----
In PHP 4.3.0, I have found a bug in declaring functions within functions:
<?
function MyZero($x) {
function GreaterThanZero() { echo "Greater"; }
function LessThanZero() { echo "LessThan"; }
function EqualToZero() { echo "Equal"; }
if ($x > 0) GreaterThanZero();
else if ($x < 0) LessThanZero();
else EqualToZero();
}
MyZero(1);
MyZero(0);
MyZero(-1);
?>
The output is:
Greater
Fatal error: Cannot redeclare greaterthanzero() (previously declared in
/home/php/public_html/teste.php:4) in /home/php/public_html/teste.php on line 4
My advice is: declare functions like you did in C, that is one function at a time. This seems to
work fine.