note 103824 added to function.filter-input
| From: | henry at henrysmith dot org | Date: | Thu, 05 May 2011 10:15:47 +0000 |
| Subject: | note 103824 added to function.filter-input | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179447@lists.php.net to get a copy of this message | ||
Marques Johansson mentioned that this works:
<?php
$test = filter_input(INPUT_GET | INPUT_POST, 'test');
?>
I've just tested it and found that it doesn't:
<?php
// assume $_GET['a'] = 1
// assume $_POST['b'] = 2
// assume $_POST['c'] = 3
// assume $_POST['d'] = 4
$a = filter_input(INPUT_GET | INPUT_POST, 'a');
$b = filter_input(INPUT_GET | INPUT_POST, 'b');
$c = filter_input(INPUT_POST | INPUT_GET, 'c');
$d = filter_input(INPUT_POST, 'd');
var_dump($a); // string(1) "1"
var_dump($b); // NULL
var_dump($c); // NULL
var_dump($d); // string(1) "4"
?>
This seems quite unpredictable behaviour, I wouldn't recommend relying on this undocumented
functionality for anything.
For reference, my PHP version is "PHP 5.3.2-1ubuntu4.8 with Suhosin-Patch (cli) (built: Apr 27
2011 05:07:22)".
----
Server IP: 69.147.83.197
Probable Submitter: 88.96.136.169
----
Manual Page -- http://www.php.net/manual/en/function.filter-input.php
Edit -- https://master.php.net/note/edit/103824
Del: integrated -- https://master.php.net/note/delete/103824/integrated
Del: useless -- https://master.php.net/note/delete/103824/useless
Del: bad code -- https://master.php.net/note/delete/103824/bad+code
Del: spam -- https://master.php.net/note/delete/103824/spam
Del: non-english -- https://master.php.net/note/delete/103824/non-english
Del: in docs -- https://master.php.net/note/delete/103824/in+docs
Del: other reasons-- https://master.php.net/note/delete/103824
Reject -- https://master.php.net/note/reject/103824
Search -- https://master.php.net/manage/user-notes.php