From 1:http://blog.sina.com.cn/s/blog_8edc37a801016yha.html
--------------------------------------------------------------------
I think the simplest is:(with this best, strpos efficiency is highest)
Strpos ($a, $b)!== False if $b is present in $ A, false otherwise.
The reason for using!== false (or = = = False) is that if the $b is exactly at the beginning of $ A, then the function returns an int (0), then 0 is false, but $b is indeed in $ A, so be sure to use!== to determine the type, to ensure that it is strictly false.
Other functions that are native to PHP, such as Strstr (), Stristr (), and so on, can be directly judged.
From 2:http://www.cnblogs.com/martin1009/archive/2012/12/26/2833831.html
------------------------------------------------------------------------------------------------
The PHP language is a powerful embedded HTML scripting language, and its ease of use allows many programmers to choose. PHP determines the inclusion of a string, you can use PHP's built-in function strstr,strpos,stristr directly to judge. You can also write a judgment function by the function of explode.
1. Strstr: Returns a string from the beginning of the judged character to the end, if there is no return value, does not contain
The code is as follows:
< PHP
/* For example in manual */
$Email = ' [email protected] ';
$domain = strstr ($email, ' @ ');
Echo $domain;
Prints @example. com
?>
2. STRISTR: It is exactly the same as the strstr. The only difference is that the STRISTR is not case sensitive.
3. Strpos: Returns a Boolean value. False and true do not say much. use "= = =" to judge. Strpos is faster than the above two functions in execution speed, and Strpos has a parameter to specify the location of the judgment, but the default is empty. Meaning to judge the entire string. The disadvantage is that the support for Chinese is not good.
The PHP judgment string contains the following code:
$str= ' abc ';
$needle= ' a ';
$pos = strpos ($str, $needle);
4. Use Explode to judge
The PHP judgment string contains the following code:
function Checkstr ($STR) {
$needle = "a";//Determine if the character "A" is included
$Tmparray = explode ($needle, $str);
if (count ($tmparray)>1) {
return true;
} else{
return false;
}
}
How PHP determines if a string contains another string