#39294 [Opn]: "Fatal error: Cannot redeclare class" for classes that use extends

From: Date: Sat, 28 Oct 2006 23:46:01 +0000
Subject: #39294 [Opn]: "Fatal error: Cannot redeclare class" for classes that use extends
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104129@lists.php.net to get a copy of this message
ID: 39294 User updated by: a79315 at hotmail dot com Reported By: a79315 at hotmail dot com Status: Open Bug Type: Class/Object related Operating System: suse 10.1 -PHP Version: 5.1.6 +PHP Version: 5.1.2 New Comment: Should read: If the "extends CTest3" is removed from file test2.inc there is no error. Previous Comments: ------------------------------------------------------------------------ [2006-10-28 23:39:01] a79315 at hotmail dot com Description: ------------ This code works fine on PHP 4 but fails on PHP 5.1.2. I know that I need to try it on the 5.1.6 version but I can't get my suse server to upgrade to it. On PHP 5.1.2 it reports "Fatal error: Cannot redeclare class". If the "extends CTest3" is removed from file test.inc there is no error. Reproduce code: --------------- File 1: test.php <? require "test2.inc"; require "test2.inc"; ?> File 2: test2.inc <? if (defined("CTEST2")) return; define("CTEST2", 1); require "test3.inc"; class CTest2 extends CTest3 { function CTest2() { print "Test2"; } } ?> File 3: “test3.inc” <? if (defined("CTEST3")) return; define("CTEST3", 1); class CTest3 { function CTest3() { print "Test3"; } } ?> Expected result: ---------------- No error Actual result: -------------- Fatal error: Cannot redeclare class ctest2 in test2.inc on line 16 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39294&edit=1

« previous php.bugs (#104129) next »