下面介绍使用方法:
1. strstr: 返回一个从被判断字符开始到结束的字符串,如果没有返回值,则不包含
<?php <BR>/*如手册上的举例*/ <BR>$email = '[email protected]'; <BR>$domain = strstr($email, '@'); <BR>echo $domain; // prints @example.com <br><br>?> <BR>
2. stristr: 它和strstr的使用方法完全一样.唯一的区别是stristr不区分大小写.
3.、本文来源gao($daima.com搞@代@#码$网搞gaodaima代码 strpos: 返回boolean值.FALSE和TRUE不用多说.用 “===”进行判断.strpos在执行速度上都比以上两个函数快,另外strpos有一个参数指定判断的位置,但是默认为空.意思是判断整个字符串.缺点是对中文的支持不好.使用方法
$str= 'abc'; <BR>$needle= 'a'; <BR>$pos = strpos($str, $needle); <BR>
4. 用explode进行判断
function checkstr($str){ <BR>$needle = "a";//判断是否包含a这个字符 <BR>$tmparray = explode($needle,$str); <BR>if(count($tmparray)>1){ <BR>return true; <BR>} else{ <BR>return false; <BR>} <BR>} <BR>