note 45528 added to language.functions
| From: | php-general at lists dot php dot net | Date: | Thu, 09 Sep 2004 19:08:42 +0000 |
| Subject: | note 45528 added to language.functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76342@lists.php.net to get a copy of this message | ||
Something that has cropped up following migration to php5 and exception handling. Consider this
code:
<?php
/*** start code snippet ***/
try
{
bar(); // this call ok
foo(); // this call will fail
function foo() { return "foo"; }
foo(); // this call works now
}
catch (Exception $e)
{
// handle the exception
}
function bar() { return "bar"; }
/*** end snippet ***/
?>
My guess is that php reads all function definitions that are in the file scope of the script, but
any functions further down the scope list [eg block scope of the try block, or block scope of an if
statement (ie conditional functions mentioned above)] are ignored until they are reached by the
program flow.
HTH Ben
----
Manual Page -- http://www.php.net/manual/en/language.functions.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45528
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45528&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45528&report=yes
Search -- http://master.php.net/manage/user-notes.php