| vrana@php.net 2005-06-10, 8:55 am |
| ID: 33293
Updated by: vrana@php.net
Reported By: elf@php.net
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
Operating System: any
PHP Version: Irrelevant
New Comment:
Think about foo() as a function defining new function. You can't call
foo() several times the same as you can't define a function several
times.
Previous Comments:
------------------------------------------------------------------------
[2005-06-10 04:31:37] elf@php.net
Description:
------------
http://www.php.net/manual/en/langua...ons.php#AEN5142
a problem exists in the sample of a manual.
this problem is not checking exist of bar.
The right example:
<?php
function foo()
{
if ( !function_exists( "bar")) <== add
{ <== add
function bar()
{
echo "I don't exist until foo() is called.\n";
}
} <== add
}
?>
Reproduce code:
---------------
<?php
error_reporting(E_ALL);
ini_set( "display_errors", "on");
function foo()
{
function bar()
{
echo "I don't exist until foo() is called.\n";
}
}
foo();
bar();
foo(); // Fatal error: Cannot redeclare bar()
?>
Expected result:
----------------
Fatal error: Cannot redeclare bar() (previously declared in
/path/for/script/foo.php:10) in /path/for/script/foo.php on line 8
Actual result:
--------------
I don't exist until foo() is called.
I don't exist until foo() is called.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33293&edit=1
|