isset bug?
| From: | Christian Calloway | Date: | Fri, 22 Aug 2003 11:16:56 +0000 |
| Subject: | isset bug? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-160426@lists.php.net to get a copy of this message | ||
Ok, here's the deal. I like to use $_GET and $_POST variables without values
to notify my scripts that some action must be taken. For example, given the
following URL:
http://blahdomain/blah.php?productid=1&edit
or given the following form element:
<input type=hidden name="edit">
My blah.php script will check if edit set using the following line:
if (isset($_REQUEST["edit"]))
{
..
}
and then it will take the appropriate actions (lets just say its updating a
record in the database). Locally I am running PHPv4.3.2, and everything
works fine. I have been working on a large web-based application for the
last month, and yesterday I put it up live. Our host unfortunately runs
PHPv4.2.1 and I have no access to the conf files (those bastards) and
globals are set to on. Low and behold, the isset function returns false when
a $_POST or $_GET variable is passed but contains no value, which would be
exactly the same thing as checking the variable itself:
if ($_REQUEST["edit"]) { }
What I want and needed to do was check for the existance of the variable,
not whether it has a value. So is this a bug, a feature or just some random
happening? Thank guys
PHP ROCKS