php.net |  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
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: closer at netnitco dot net
New email:
PHP Version: OS:

 

 [2003-11-04 14:16 UTC] closer at netnitco dot net
Description:
------------
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:
---------------
<?php
$new_obj = new new_class;
$new_obj->hello ();

class new_class
	{
	function hello ()
		{
		echo "Hello";
		}
	}
?>

Expected result:
----------------
Hello

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

Patches

Pull Requests

History

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

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 00:01:36 2025 UTC