Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 PHP 中编码时,如果我需要在我使用的字符串中匹配短语
if(strpos("findmeinstring","findme")>0)
但是 strpos 不是正确的方法,正确的方法是什么?
用这个:
if (strpos("findmeinstring","findme") !== false)
从PHP 手册:
此函数可能返回布尔值 FALSE,但也可能返回计算结果为 FALSE 的非布尔值,例如 0 或“”。请阅读有关布尔值的部分以获取更多信息。使用=== 运算符测试此函数的返回值。
我认为strpos是正确的方法。但是你应该使用 ===
if(strpos("findmeinstring","findme") !== false)