如何在php中找到2个不同的字符串(string1或string2)
返回整数(如果找到字符串,则返回位置),如果未找到字符串,则返回如何在php中找到2个不同的字符串(string1或string2),php,html,Php,Html,返回整数(如果找到字符串,则返回位置),如果未找到字符串,则返回false。那你的测试呢 if(strpos($input, '[key1]') === true or strpos($input, 'key2') === true) 将永远不会通过,因为整数或false永远不会是==true。相反,请更改测试以检查strpos的结果是否为false: if(strpos($input, '[key1]') !== false or strpos($input, 'key2') !== fal
false
。那你的测试呢
if(strpos($input, '[key1]') === true or strpos($input, 'key2') === true)
将永远不会通过,因为整数或false
永远不会是==true
。相反,请更改测试以检查strpos
的结果是否为false
:
if(strpos($input, '[key1]') !== false or strpos($input, 'key2') !== false)
等等,那么如何找到字符串呢?@TunkuSalim你的问题并没有说任何关于找到字符串的事情,只说它是否存在not@mickmackusa这不是代表的问题,而是帮助人们的满足感。请帮助人们找到预先存在的答案。现在太晚了,我明白了。