Jump to content

PHP filter code ( beginners' question )


Truman
 Share

Recommended Posts

I'm learning PHP from w3school tutorial and I need explenation about "!", for example take a look at this code:

 

<?php
$int = 100;

if (!filter_var($int, FILTER_VALIDATE_INT) === false) {
echo("Integer is valid");
} else {
echo("Integer is not valid");
}
?>

 

Why is there exclamation mark in this code?

And one more thing: if filter_validate_int ( or any other filter ) is false that is because the filter didn't catch any error and therefore, in this case integer, is valid. Did I get this correct?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...