Re: Function Declared in Included File Not Being Found

From: Date: Fri, 11 May 2007 23:15:56 +0000
Subject: Re: Function Declared in Included File Not Being Found
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-254826@lists.php.net to get a copy of this message
On May 11, 2007, at 1:43 PM, Chris wrote:
Hello, According to the PHP manual on functions (http://www.php.net/manual/en/language.functions.php): "In PHP 3, functions must be defined before they are referenced. No such requirement exists since PHP 4. Except when a function is conditionally defined..." If that is true then why does the following not work as I expect? I expect the result to be "Function was called!" but it actually is "Function test() does not exist!". File: a.php <?php if (function_exists('test')) {
    echo test();
} else {
    echo "Function test() does not exist!";
} require 'b.php'; ?> ------------------------------- File: b.php <?php require 'c.php'; ?> ------------------------------- File: c.php <?php function test() {
    return "Function was called!";
} ?> Chris
One reason I believe is that including a file in an included file will not work. file a includes file b wnich includes file c, code in file c will not register. (if I remember the manual correctly) Jeff K

« previous php.general (#254826) next »