php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28711 $QUERY_STRING is define with null instead of stay undefine when no query string
Submitted: 2004-06-09 16:42 UTC Modified: 2005-01-22 01:00 UTC
Votes:11
Avg. Score:2.5 ± 1.0
Reproduced:3 of 5 (60.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: sikachu at beezone dot net Assigned:
Status: No Feedback Package: Unknown/Other Function
PHP Version: 5.0.0RC3 OS: Windows 2000
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: sikachu at beezone dot net
New email:
PHP Version: OS:

 

 [2004-06-09 16:42 UTC] sikachu at beezone dot net
Description:
------------
I upgraded from PHP 4.3.4 to PHP 5.0 RC3 yesterday. When I tried to run the script that check for the query string and then refresh to the page, the query string return the invalid value. This behavior I found only in PHP 5.0 RC3

I'll show you the result with these thing:
echo $QUERY_STRING;
isset($QUERY_STRING);
$QUERY_STRING == "";

For example, assume that the script URL is http://somewhere.com/index.php

If I call it like this: http://somewhere.com/index.php?foo

echo $QUERY_STRING;    // show foo
isset($QUERY_STRING);  // return true
$QUERY_STRING == "";   // return false

But, here is the problem. If I call it like this: http://somewhere.com/index.php

echo $QUERY_STRING;    // show ""(nothing)
isset($QUERY_STRING);  // return true  << unexpected
$QUERY_STRING == "";   // return true

The code that I use for test will be in the next section.

My PHP configuration based on php.ini-dist. I changed register_global to be On, and then add php_mysql & php_mysqli extension to it.

Reproduce code:
---------------
if(isset($QUERY_STRING))
{
	echo "Your query string is defined\n";
}
if($QUERY_STRING == "")
{
	echo "Your query string is null\n";
}
if($QUERY_STRING == " ")
{
	echo "Your query string contain just a space\n";
}

echo "Here is your query string: '".$QUERY_STRING."'";

Expected result:
----------------
Your query string is null
Here is your query string: ''

Actual result:
--------------
Your query string is defined
Your query string is null
Here is your query string: ''

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-09 16:44 UTC] sikachu at beezone dot net
Change the version number in topic from RC2 to RC3 ...
 [2004-06-09 16:46 UTC] sikachu at beezone dot net
Clearify the bug summary ...
 [2004-06-10 09:18 UTC] imprestavel at gameguru dot com dot br
I think php4 does that too (just tested, but register_globals is off)
Maybe you are confusing isset with empty


"isset -- Determine whether a variable is set
...
Returns TRUE if var exists; FALSE otherwise."


"empty -- Determine whether a variable is empty
...
empty() returns FALSE if var has a non-empty and non-zero value. In otherwords, "", 0, "0", NULL, FALSE, array(), var $var;, and objects with empty properties, are all considered empty. TRUE is returned if var is empty."


You may find that information here:
http://www.php.net/isset
http://www.php.net/empty

Hope it helps
 [2004-06-10 17:48 UTC] sikachu at beezone dot net
Well ... I used isset() with $QUERY_STRING to check the query all the time. Also, my server still PHP 4.3.7 and it's at http://ragnarok.beezone.net . 

On there, If you type in 'http://ragnarok.beezone.net', it will load itself because the isset($QUERY_STRING) is false! And if I type something like 'http://ragnarok.beezone.net/?board' That will trigger the code and redirect to the page we provide !

Can somebody test and confirm that just because my server use cgi (php.exe) instead of isapi module (php5isapi.dll)?

Thanks anyway, imprestavel. I think if I change the script whole site to use empty(), it may works. But I sill confuse with this behavior.
 [2004-06-11 01:20 UTC] imprestavel at gameguru dot com dot br
Tested with both (4.3.7 and 5RC3) with register_globals On and Off (on both) and they all had the same behavior
Maybe its some weird thing between php and the server...

Your 4.3.7 server is running IIS5, right?
Maybe it only passes query string to cgi if its not empty...
In that case, the only reason why your script works(while it shouldnt), is because IIS works how it shouldnt hehe

Anyway, i think you should change isset to empty for cases like the one you described

But lets wait for someone from the staff to reply...
 [2004-06-11 01:24 UTC] imprestavel at gameguru dot com dot br
Sorry...
I meant i tested with both (4.3.7 and 5RC3) *CGI versions* with register_globals On and Off (under Apache2)
 [2004-06-18 15:04 UTC] sikachu at beezone dot net
Looks like nobody else got a same problem and also no staff come to this topic regarding this bug. I'm fine right now with using empty() instead isset(). So, I may close this one after a while.

I really want somebody to have a same environment (PHP5 ISAPI + IIS5) and test with me. I want to see that we got the same result or not
 [2005-01-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-11-29 16:46 UTC] schindler dot kimberly at yahoo dot com
the truth
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC