我如何在 PHP 中检查某些字符串是否包含正斜杠?
最佳答案
使用 strpos()
检查事件
if (strpos($string, '/') !== FALSE) // Found
Returns the position as an integer. If needle is not found, strpos() will return boolean FALSE.
这比正则表达式和大多数其他方法更快,因为它会在第一次出现时停止检查。
关于PHP 正斜杠匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6183747/