php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2036 "Fatal error on line 0" with class definitions
Submitted: 1999-08-11 16:49 UTC Modified: 1999-08-14 07:09 UTC
From: weyrick at roadsend dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Beta 2 OS: Linux saidin 2.3.2 #1 SMP Sun Ma
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: weyrick at roadsend dot com
New email:
PHP Version: OS:

 

 [1999-08-11 16:49 UTC] weyrick at roadsend dot com
when the following code is run w/ display_errors on and error_reporting 65527 the following error is generated:

Fatal error:  Cannot redeclare class testclass in
/opt/apache2/htdocs/chat/debug/crash.php on line 0

The script stops execution immediately after the first (and only) definition of testClass


<?

class arrayClass {

 var $myArray;

              function add($key, $val) {
                              $this->myArray[$key] = $val;
              }

              function output() {
                              echo "size of myArray is ".sizeof($this->myArray)."\n\n<br><br>";
                              foreach($this->myArray as $k => $v) {
                                              echo "$k => $v<br>\n";
                              }
              }


}


/* putting this call here would execute php info correctly */
/* phpinfo(); */

/* execution aborts after compiling this class?? */
class testClass {

              var $myArrayClass;

 /* constructor ... */
              function testClass() {
                              $this->myArrayClass = new arrayClass;
              }


}

/* the script never reaches this point, the server simply returns
    document contained no data                                                                      */
phpinfo();

class mainClass {

              var $myTestClass;

              function newClass() {
                              $this->myTestClass = new testClass;
                              return $this->myTestClass->myArrayClass;
              }

              function output() {
                              $this->myTestClass->myArrayClass->output();
              }
}

$myMainClass = new mainClass;
$arrayTestClass = $myMainClass->newClass();
$arrayTestClass->add("test1","val1");
$arrayTestClass->add("test2","val2");

$myMainClass->output();

?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-08-14 07:09 UTC] zeev at cvs dot php dot net
TestClass was a built-in class, and thus you can't redeclare it.
In the current CVS it's renamed to OverloadedTestClass.

The problem with the line number was fixed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 21:01:35 2025 UTC