Help understanding if () === 0
Posted: Sat Apr 23, 2011 3:35 pm
As a beginner of PHP I am having trouble understanding the code
if(preg_match("/^[A-Z][a-zA-Z -]+$/", $_POST["name"]) === 0)
What I understand--
The format for a PHP if statement is: if (condition) So the condition from above is: preg_match("/^[A-Z][a-zA-Z -]+$/", $_POST["name"]) === 0
Now for preg_match--preg_match ( pattern , subject) So the pattern is "/^[A-Z][a-zA-Z -]+$/" and the subject $_POST["name"]
What I do not understand
But now, I am confused how does the === 0 work. I am assuming the 0 has something to do with false, but
1) why the ===
2) why the 0
3) Also is there an easier way to write this so I can understand it as a beginner.
Thanks for you help in this matter.
if(preg_match("/^[A-Z][a-zA-Z -]+$/", $_POST["name"]) === 0)
What I understand--
The format for a PHP if statement is: if (condition) So the condition from above is: preg_match("/^[A-Z][a-zA-Z -]+$/", $_POST["name"]) === 0
Now for preg_match--preg_match ( pattern , subject) So the pattern is "/^[A-Z][a-zA-Z -]+$/" and the subject $_POST["name"]
What I do not understand
But now, I am confused how does the === 0 work. I am assuming the 0 has something to do with false, but
1) why the ===
2) why the 0
3) Also is there an easier way to write this so I can understand it as a beginner.
Thanks for you help in this matter.