The following describes how to use the attributes of php character and string inclusion method :? 1. strstr: returns a string starting from the judged character to the end. If no return value exists, it does not contain? The code is as follows: & lt ;? Php ????? /* Example in the manual */????? $ Email = 'User php determines the inclusion method attributes of characters and strings
The following describes how to use :?
1. strstr: returns a string starting from the judged character to the end. If no return value exists, it does not contain?
The code is as follows:
???? /* Example in the manual */?
???? $ Email = 'User @ example.com ';?
??? $ Domain = strstr ($ email ,'@');?
???? Echo $ domain; // prints @ example.com?
?>?
2. stristr: it is used exactly the same as strstr. The only difference is that stristr is case insensitive .?
3. strpos: returns a boolean value. FALSE and TRUE. use "=" to judge. the execution speed of strpos is faster than that of the above two functions. In addition, strpos has a parameter that specifies the location for judgment, but is left blank by default. it indicates determining the entire string. the disadvantage is poor support for Chinese characters. how to use it?
The code is as follows:
$ Str = 'abc ';?
$ Needle = 'a ';?
$ Pos = strpos ($ str, $ needle );?
4. use explode to determine the code as follows:
Function checkstr ($ str ){?
????? $ Needle = "a"; // determines whether the string contains?
???? $ Tmparray = explode ($ needle, $ str );?
???? If (count ($ tmparray)> 1 ){?
?????? Return true ;?
??? } Else {?
?????? Return false ;?
??? }?
}?