1.strpos() function is used to find whether a certain substring exists in the target string. If it exists, it returns the position information of the substring, otherwise it returns false. When the position of the substring is at the beginning of the target string, the returned The position information is 0, so you need to use a constant judgment in the if statement, that is, if(strpos(...) === false), because 0==false is established in php; the same problem also occurs in strstr() function, the function returns the substring found for the first time and all characters before the substring. It can also return the substring and all characters after it by setting parameters (PS: the returned string contains substrings). When strstr(' 43210','0'), the function returns '0' == false, so when using the strstr function instead of strpos for determination, you must also pay attention to the identity principle, otherwise it may cause errors in judgment; if you only need to determine whether the substring exists, it is faster to use strpos.
2.
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above has introduced the various pitfalls of PHP strings, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.