php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14952 $_GET and $HTTP_GET_VARS are separate arrays
Submitted: 2002-01-09 12:38 UTC Modified: 2002-01-09 12:43 UTC
From: ramses0 at yahoo dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.1.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ramses0 at yahoo dot com
New email:
PHP Version: OS:

 

 [2002-01-09 12:38 UTC] ramses0 at yahoo dot com
blah.php
<?php

	print_r( $HTTP_GET_VARS );
	print_r( $_GET );

	echo "<hr>";
	$_GET['test'] = 1;
	echo "<hr>";

	print_r( $HTTP_GET_VARS );
	print_r( $_GET );

?>

Results from blah.php
---------------------
Array ( ) Array ( ) 
Array ( ) Array ( [test] => 1 )

Results from blah.php?test=test
---------------------
Array ( [test] => test ) Array ( [test] => test ) 
Array ( [test] => test ) Array ( [test] => 1 ) 


Aside from the performance/memory implications of having two separate arrays (ie: http://blah.com/blah.php?text=[shakespeare]&spell_check=1), it's really annoying when trying to propagate information to a moduralized script which normally takes data off the get-string.

Here is my patch:  $_GET =& $HTTP_GET_VARS;   It halves the memory requirements of PHP's default arrays, and behaves much closer to what an end-user would expect.  I am willing to bet that NOBODY wants $_GET['blah'] = 'test'; echo $HTTP_GET_VARS['blah']; to fail in mysterious ways.

Why is this not done in the first place?  I have checked on the mailing lists and in the bug archives, but couldn't find any previous discussion.  Send me an email at ramses0@yahoo.com if there is a good reason for this, or if I am missing something important.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-09 12:43 UTC] jan@php.net
the $_* arrays are intended to be seperate from ther $HTTP_*_VARS arrays.
The new arrays are so called "super-global". You don't hve to introduce them nito function-scope with global. This is a feature no bug => Bogus
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri May 27 12:07:03 2022 UTC