filter_has_var

filter_has_var function checks the variable available or not. The same result can be achieved by using isset() function also but the advantage of filter_has_var is it checks the specified type of input ( source ) is available or not. If we expect the variable to be available by POST method and not by GET method for form posting then the same can be checked by using filter_has_var function in PHP. Here is the syntax
bool filter_has_var(TYPE, variable_name);
Here is one example
<?php
if(filter_has_var(INPUT_GET,'REMOTE_ADDR')){
echo "Yes true $_GET[book_id]";
}else{
echo "No false $_GET[book_id]";
}
?>
The above code will display the status of book_id variable is available through GET method only. ( file_name.php?book_id=3 )
The possible type of availability are
INPUT_POST, 
INPUT_GET, 
INPUT_COOKIE,
INPUT_SERVER, 
INPUT_ENV
fillter_has_var is a better way than isset() function to to check the existence of a variable
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com




    Post your comments , suggestion , error , requirements etc here .




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2023 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer