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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
7 + 21 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

History

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

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC