Edit report at http://bugs.php.net/bug.php?id=53508&edit=1
ID: 53508 User updated by: exsystemchina at gmail dot com Reported by: exsystemchina at gmail dot com Summary: Class not found caused by require_once Status: Open Type: Bug Package: Scripting Engine problem Operating System: Mac OS X 10.6 PHP Version: 5.3.3 Block user comment: N Private report: N New Comment: //System.php <?php require_once 'Utilities.php'; class TJustTest { public function __construct() { var_dump(get_declared_classes()); } } interface IInterface { public function Supports($AInterface); } class TObject implements IInterface { public function Supports($AInterface) { echo 'hi'; } } class TJustAnotherTest { public function Foo() { echo 'foo'; } } ?> //Utilities.php <?php require_once 'System.php'; class TSomethingBoring { public function Boring() { echo 'really boring'; } } $a=new TJustTest(); class TMustBeWrong extends TObject { function Tragedy() { echo 'this will not be seen.'; } } ?> Just run System.php to see the fatal error with other classes before TObject loaded successfully inside System.php Previous Comments: ------------------------------------------------------------------------ [2010-12-14 13:14:52] exsystemchina at gmail dot com ok, i have just know that a login is needed to download the zip file..... now i have shorten the buggy code. ------------------------------------------------------------------------ [2010-12-13 10:18:21] ahar...@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2010-12-10 13:39:52] exsystemchina at gmail dot com I found that if I put require_once at the end of the php file, the fatal error won't appear any more... just inspired by another bug report. ------------------------------------------------------------------------ [2010-12-09 15:47:56] exsystemchina at gmail dot com Description: ------------ A weird bug, appears only when the script contains require_once: A class is defined with an interface implemented, but the PHP interpreter produces a fatal error saying class not defined. But everything goes well if the class doesn't implemented an interface. Test script: --------------- Download this file, and unzip it: http://files.cnblogs.com/ExSystem/FrameworkDSW.zip Make sure your php include_path contains the parent directory of FrameworkDSW, and to set error reporting level to E_ALL in case. Run FrameworkDSW\System.php, and get the fatal error. ****And only the classes defined before the declaration of TObject inside System.php are declared succesfully(I guess it by invoking get_declared_classes()). Then modify the line 285 of System.php to class TObject { rather than class TObject implements IInterface { and run it again, to see the difference. ****And all the classes inside System.php are declared successfully. Expected result: ---------------- <Nothing> Actual result: -------------- <br /> <b>Fatal error</b>: Class 'TObject' not found in <b>{your_include_path}\FrameworkDSW\Utilities.php</b> on line <b>81</b><br /> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53508&edit=1