php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #18452 Superglobals appear to not work...
Submitted: 2002-07-20 22:39 UTC Modified: 2002-11-10 16:07 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dilbert at hack3r dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.2.1 OS: OpenBSD
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: dilbert at hack3r dot com
New email:
PHP Version: OS:

 

 [2002-07-20 22:39 UTC] dilbert at hack3r dot com
An example of this failure can be seen here:
http://roothack.org/Articles/test.php?var=value

The Source to that page is here:
<?
// PHP 4.2.1
// get like: file.php?name=hi
// Isn't $_GET supposed to be "superglobal" ?

	print_r($_GET); // Works!
	echo "<br><hr>";
	function pr1() { print_r($_GET); } // DOESN'T WORK!
	echo "<br><hr>";
	$h = "_GET";
	print_r($$h); // Works!
	echo "<br><hr>";
	function pr2() { $g = "_GET"; print_r($$g); }  // DOESN'T WORK!
	echo "<br><hr>";
	function pr3() { global $_GET; print_r($_GET); } // DOESN'T WORK!??

?>

Information about the server can be found here:
http://roothack.org/~articles/test2.php

(its phpinfo();)

Please tell me I'm not crazy... ;)

Ted Kaminski

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-20 22:41 UTC] dilbert at hack3r dot com
An example of this failure can be seen here:
http://roothack.org/articles/test.php?var=value

(case...)
 [2002-07-20 22:42 UTC] dilbert at hack3r dot com
An example of this failure can be seen here:
http://roothack.org/~articles/test.php?var=value

(wonder how many tries this is going to take...)
 [2002-07-21 14:21 UTC] tal@php.net
Of course it doesn't work, you don't call the functions...

-Tal
 [2002-07-22 19:54 UTC] dilbert at hack3r dot com
you just told me I was crazy ;)

but okay, I fixed that problem (heh)

this STILL isn't a bogus bug, however... Look at the example page i supplied above,

....
	echo "<br><hr>";
	$h = "_GET";
	print_r($$h); // Works!
	echo "<br><hr>";
	function pr2() { $g = "_GET"; print_r($$g); }  // DOESN'T WORK!
	pr2();
....

That part is still true. Comments and all.

Now, thats the bug I was dealing with previously (before i screwed up and figured all superglobals didn't work :/)

I knew I messed something up, at least I've finally got this refined...

Am I missing something again, or have I finally nailed it?

Ted
 [2002-11-10 12:01 UTC] php at pwoods dot fsnet dot co dot uk
try using $HTTP_GET_VARS rather than $_GET... I am new to this so I might be wrong but the $_GET and $_POST etc seem deprecated in this version.
 [2002-11-10 16:07 UTC] philip@php.net
autoglobals (superglobals) don't work as variable variables. This is known and comes up every so often.  It's documented here:

http://www.php.net/manual/en/language.variables.variable.php

I've added a note at php.net/variables.predefined and it'll show up within the next few days.  Am marking this as a closed documentation bug.

Regarding the last note, autoglobals have never been nor will they ever be deprecated.  The older $HTTP_*_VARS are deprecated yet I'm pretty sure they'll be around forever.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Aug 17 10:00:03 2025 UTC