Function Declared in Included File Not Being Found

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux