#39294 [NEW]: "Fatal error: Cannot redeclare class" for classes that use extends
| From: | a79315 at hotmail dot com | Date: | Sat, 28 Oct 2006 23:39:01 +0000 |
| Subject: | #39294 [NEW]: "Fatal error: Cannot redeclare class" for classes that use extends | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-104124@lists.php.net to get a copy of this message | ||
From: a79315 at hotmail dot com
Operating system: suse 10.1
PHP version: 5.1.6
PHP Bug Type: Class/Object related
Bug description: "Fatal error: Cannot redeclare class" for classes that use extends
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 bug report at http://bugs.php.net/?id=39294&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39294&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39294&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39294&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39294&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=39294&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39294&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39294&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39294&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39294&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39294&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=39294&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=39294&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39294&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39294&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39294&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39294&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39294&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39294&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39294&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39294&r=mysqlcfg