Re: nested includes fails?

From: Date: Tue, 04 May 2004 11:34:54 +0000
Subject: Re: nested includes fails?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-9656@lists.php.net to get a copy of this message
Ilya Sher wrote:
Tumurbaatar S. wrote:
'common.php' contains some class definition and PHP5 fails with 'PHP Fatal error: Cannot redeclare class ... in common.php...' when script C.php starts. The file including map is: A.php: require_once(common.php) B.php: require_once(common.php) C.php:
    require_once(A.php)
    require_once(B.php)
That is bug? When only one file is included (A or B), the contents of 'common.php' is available, i.e. nested require works. Only fails when nested and multiple require. P.S. I use PHP5 RC2 running as CGI on WinXP/IIS.
That seems to be the correct behaviour for both PHP5 and PHP4. Really sorry for misleading.
Should read "... for PHP4" and I assume for PHP5.
A class should never be defined twice - but that's the case when you include or execute somehow else the code with class definition (common.php) more than once.


« previous php.internals (#9656) next »