What is the use of using filter_has_var () over isset ()

I am a little confused by what I used filter_has_var($_POST['id'])over isset($_POST['id']).

Can someone please tell me if this is just a function of an alias?

+5
source share
4 answers

Not alot;) According to the filter_has_var manual page, one user finds it faster filter_has_var. It is also worth noting ... filter_has_vardoes not work on a live array ( $_POST), but on the actual input provided ... if you ever add / remove / update that in this array you will not see these changes with a call filter_has_var(while it issetwill reflect the current state)

By the way, use filter_has_var(INPUT_POST,"id");

: , , filter_has_var PHP 5.2.0 ( ), isset PHP4 + 5. , isset ( PHP3)?

+11

,

filter_has_var($_POST['id'])

filter_has_var(INPUT_POST, 'id')

-, $_POST. , , , $_POST - PHP .

+5

, filter_has_var(INPUT_POST, 'id') isset($_POST['id']).

, isset false, $_POST['id'] is NULL; key_exists('id', $_POST), .

, , filter_has_var $_POST (. ).

+1

Function does not check live array

<?php
$_GET['a'] = 1;
echo filter_has_var(INPUT_GET, 'a') ? 'Exist' : 'Not exist';

will be printed Does not exist

0
source