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 中使用 preg_match 检查两个单词(例如“sheep”和“goat”)?
例子:
if (!preg_match(goat|sheep)) header(' Location: / ');
谢谢!
只需这样做:
if (!preg_match('~\b(?:goat|sheep)\b~i', $yourstring)) header('Location: /');
更多信息在这里和这里