SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP Filter


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 = 'userid@example.com';
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

Be the first to post comment on this article :

Post Comment This is for short comments only. Use the forum for more discussions.
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked

HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2015 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer