#41383 [NEW]: Function in 'required' File doesn't Appear to Exist
| From: | chris at dented-planet dot net | Date: | Sun, 13 May 2007 10:38:59 +0000 |
| Subject: | #41383 [NEW]: Function in 'required' File doesn't Appear to Exist | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-112597@lists.php.net to get a copy of this message | ||
From: chris at dented-planet dot net
Operating system: Mac OS X
PHP version: 5.2.2
PHP Bug Type: Unknown/Other Function
Bug description: Function in 'required' File doesn't Appear to Exist
Description:
------------
The documentation on functions
(http://www.php.net/manual/en/language.functions.php) says:
"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..."
I don't understand why the following code (in three different files BTW)
doesn't work as expected. It doesn't seem to be conditionally defined.
Tested with PHP 4.4.4-CLI, PHP 5.2.1, PHP 5.2.2.
I am openminded that this may not be a bug but I can't seem to find an
explanation.
Reproduce code:
---------------
FILE a.php:
<?php
error_reporting(E_ALL | E_NOTICE);
echo "FILE 'a.php'\n";
if (function_exists('test')) {
echo test();
}
else {
echo "function 'test()' doesn't exist!\n";
}
require 'b.php';
?>
------
FILE b.php
<?php
echo "FILE 'b.php'\n";
require 'c.php';
?>
------
FILE c.php
<?php
echo "FILE 'c.php'\n";
function test()
{
return "function test() was called!\n";
}
?>
Expected result:
----------------
SIGNIFICANT expected result: 'function test() was called!' is echoed.
Other output is for debugging.
Actual result:
--------------
Actual result: 'function 'test()' doesn't exist!' is echoed.
--
Edit bug report at http://bugs.php.net/?id=41383&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41383&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41383&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41383&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41383&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41383&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41383&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41383&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41383&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41383&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41383&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41383&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41383&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41383&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41383&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41383&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41383&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41383&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41383&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41383&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41383&r=mysqlcfg