Python有很大:如果子字符串中的字符串,像这样:PHP版本,如果在
if "fox" in "The quick brown fox jumps over the lazy dog":
print True
确实做PHP有东西相当于这个?
Python有很大:如果子字符串中的字符串,像这样:PHP版本,如果在
if "fox" in "The quick brown fox jumps over the lazy dog":
print True
确实做PHP有东西相当于这个?
有几种方法。其一是:
if(stristr('fox','The quick brown fox jumps over the lazy dog') !== FALSE){
...code
}
http://php.net/manual/en/function.stristr.php
stripos函数和其他人可能更有效。见PHP String Functions
它的`===`|`!==`用于比较它的类型`==`|`!=`用于值比较,`=`用于指定 – RobertPitt 2010-12-02 21:41:06
有三个,我能想到的:substr,strpos和strstr。其中的每一个都区分大小写,并且这些功能也有不区分大小写的版本。 PHP有一些荒谬的字符串处理命令,所以你只需仔细阅读string section of the manual,直到看到你想要的。
感谢关于严格比较的注释 – imns 2010-12-02 21:31:06