|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26121 Object defined before object - error
Submitted: 2003-11-04 14:16 UTC Modified: 2003-11-18 15:33 UTC
From: closer at netnitco dot net Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.0.0b2 (beta2) OS: Redhat Linux 9.0 / Apache 2.0.46
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: closer at netnitco dot net
New email:
PHP Version: OS:


 [2003-11-04 14:16 UTC] closer at netnitco dot net
With PHP 4 you could create the object variable before the actual object was defined. This doesnt seem to be true in 5. If you move lines 2 and 3 of the code to the bottom the script oes work, but this does break backward compatibility.

Reproduce code:
$new_obj = new new_class;
$new_obj->hello ();

class new_class
	function hello ()
		echo "Hello";

Expected result:

Actual result:
Fatal error: Class 'new_class' not found in /usr/local/apache2/htdocs/scripts/class_test.php on line 2


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-18 15:33 UTC]
This is expected and correct behaviour.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Aug 16 10:05:45 2022 UTC