php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #738 $GLOBALS dislike array element and class field
Submitted: 1998-09-11 13:35 UTC Modified: 1998-09-25 19:52 UTC
From: mquinson at zeppelin-cb dot de Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 3.0.3 OS: win95 ; freeBSD
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: mquinson at zeppelin-cb dot de
New email:
PHP Version: OS:

 

 [1998-09-11 13:35 UTC] mquinson at zeppelin-cb dot de
(is it a bug or an improvement?)

I create
class test {
	var $value;
	function test() {
		$this->value = 2;
}	}
$myTest = new test();
And then, if I try to access to $GLOBALS["myTest->value"], i get an empty string.
and I would like to get $myTest->value...
To fix it, i have to ereg("^([a-zA-Z0-9_-]*)->([a-zA-Z0-9_-]*)",$name,$regs) all the strings I want to pass to $GLOBALS. It's not so usefull... 

The same is true with $GLOBALS["foo[0]"];

Thanks for your time.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-09-25 19:52 UTC] zeev
You only have the syntax wrong.
To access $foo[0] in the global scope, you need to access
$GLOBALS["foo"][0].
To access $foo->bar in the global scope, you need to access
$GLOBALS["foo"]->bar.

Zeev
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Mar 25 19:01:29 2025 UTC