The following describes how to use:
1. strstr: Returns a string from the beginning to the end of the judged character. If there is no return value, it does not include
Copy the code The code is as follows:
/*As shown 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 not case-sensitive.
3. strpos: Returns a boolean value. Needless to say, FALSE and TRUE. Use "===" Judgment.strpos is faster than the above two functions in terms of execution speed. In addition, strpos has a parameter to specify the position of judgment, but the default is empty. It means to judge the entire string. The disadvantage is that the support for Chinese is not good. How to use
Copy code The code is as follows:
$str= 'abc';
$needle= 'a';
$pos = strpos($str, $needle);
4. Use explode to judge
Copy code The code is as follows:
function checkstr($str){
$needle = "a";//Determine whether the character a is included
$tmparray = explode($needle ,$str);
if(count($tmparray)>1){
return true;
} else{
return false;
}
}
http://www.bkjia.com/PHPjc/319442.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319442.htmlTechArticleThe following describes how to use it: 1. strstr: Returns a string from the beginning to the end of the character being judged, if there is no The return value does not include the copy code. The code is as follows: ?php /*As shown in the manual...