php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32578 inclusion bug unable to access global object methods
Submitted: 2005-04-05 01:25 UTC Modified: 2006-04-23 07:40 UTC
From: theteofscuba at hotmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5CVS-2005-04-05 (dev) OS: XP
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: theteofscuba at hotmail dot com
New email:
PHP Version: OS:

 

 [2005-04-05 01:25 UTC] theteofscuba at hotmail dot com
Description:
------------
see title. i've encountered this problem where the latest snapshot build will not execute methods of global objects.

Reproduce code:
---------------
file test1.php:

<?php
global $phpTest;
require_once("test2.php");
$phpTest = new PHPTEST();
?>


file test2.php:

<?php
global $phpTest;

class PHPTEST
{
	public $var;
	function DoSomething()
	{
		echo "hi it worked";
	}
}

require_once("test3.php");

?>

file test3.php:

<?php
global $phpTest;
$phpTest->var = "we can set variables just fine";
$phpTest->DoSomething(); // ka-boom
?>

Expected result:
----------------
.

Actual result:
--------------
Fatal error: Call to undefined method stdClass::DoSomething() in C:\php\test3.php on line 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-05 01:27 UTC] theteofscuba at hotmail dot com
this was just a silly mistake. I failed to see that the class object was not defined at the time test3.php executes
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 17:01:34 2025 UTC