ID: 33293 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -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] [EMAIL PROTECTED] Description: ------------ http://www.php.net/manual/en/language.functions.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