We can check a variable by using a particular type of filter by using filter_var() function. This function takes the variable and the ID or name of the filter as input and checks the variable. It returns True of False based on the checking output. Here is the syntax.

bool=filter_var(variable, Filter ID,optional );

We will try with an example with book_id as variable

if(filter_var($_GET['book_id'],257)){ // id 257 is for validating integers
echo "Yes true book_id validation passed";
echo "No false book_id validation failed";

You can get list of filter ID here

echo "Yes true $book_id";
echo "No false $book_id";

IN the above code we have not user filter id and in that place we have used filter Name. Now let us try one email validation by using email filter

$email = '';
echo " Yes true, email validation passed";
echo "No false, email validation failed";

We can replace the email filter name with email filter ID ( 274 ) , just change the above line with this


Your Rating


Post Comment This is for short comments only. Use the forum for more discussions.

HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2017 All rights reserved worldwide Privacy Policy Disclaimer