To note: filter_has_var() is a bit faster than isset()
filter_has_var
(PHP 5 >= 5.2.0)
filter_has_var — 指定した型の変数が存在するかどうかを調べる
説明
bool filter_has_var
( int $type
, string $variable_name
)
パラメータ
- type
-
INPUT_GET、INPUT_POST、 INPUT_COOKIE、INPUT_SERVER、 INPUT_ENV のいずれか。
- variable_name
-
調べたい変数の名前。
返り値
成功した場合に TRUE を、失敗した場合に FALSE を返します。
filter_has_var
drm at melp dot nl
16-Jan-2009 09:54
16-Jan-2009 09:54
Please note that the function does not check the live array, it actually checks the content received by php:
<?php
$_GET['test'] = 1;
echo filter_has_var(INPUT_GET, 'test') ? 'Yes' : 'No';
?>
would say "No", unless the parameter was actually in the querystring.
Also, if the input var is empty, it will say Yes.
julien dot pauli at doctorrock dot eu
08-Jan-2007 12:43
08-Jan-2007 12:43
<?php
filter_has_var(INPUT_POST, 'submit')
?>
is same as
<?php
isset($_POST['submit'])
?>
