Problem
Want to know if a string contains a specific substring. For example, want to see if an email address contains an @.
Solve
if (Strpos ($_post[' email '), ' @ ') = = = False) { echo ' there is no @ in the e-mail address! ';}
Discuss
The return value of Strpos () is the first occurrence of a substring in a string
If there is no substring at all in the string, Strpos () returns false
If the substring is at the starting position of the string, Strpos () returns 0 because position 0 represents the starting position of the string.
To distinguish between 0 and false, you must use the identity operator (= = =) or the non-identity operator (!==)
The above example uses the = = = To compare the return value of Strpos () with false. This test succeeds only if Strpos () returns false, and if Strpos () returns 0 or any other number, the test will not succeed