note 45805 added to reserved.variables

From: Date: Sun, 19 Sep 2004 22:45:08 +0000
Subject: note 45805 added to reserved.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-76992@lists.php.net to get a copy of this message
Just a note on $_REQUEST variables, especially in concern with $_GET and $_POST. If you have two variables of the same name, one using GET (url assignment) and the other inside a form set for POST (hidden input for example), if you try to read the variable through $_REQUEST, you'll only ever get the $_POST result. While it's easier to use $_REQUEST for variables only assigned to one area (POST/GET/COOKIE), to bypass the above problem in situations where the same variable might be called in two formats (GET/POST), one could do the following: <?php $testVar = isset($_POST['testVar']) ? $_POST['testVar'] : $_GET['testVar']; ?> ---- Manual Page -- http://www.php.net/manual/en/reserved.variables.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45805 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45805&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45805&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76992) next »