【发布时间】:2015-08-13 20:32:03
【问题描述】:
我目前正在使用 PHP Stripos OK 来查找 URL 中存在的单词(鹦鹉)。
但是我现在需要检查 URL 中是否存在 2 个单词(green 和 parrots),即它们都必须存在。
这是当前代码:
if (stripos($_SERVER['REQUEST_URI'],'-parrots') !== false)
{echo '<div class="clear"></div><a href="http://www.example.com/parrots/" class="btn"> >> Parrots</a>';}
上面的效果很好。
我试过的两个词:
if (stripos($_SERVER['REQUEST_URI'],'-green','-parrots') !== false)
{echo '<div class="clear"></div><a href="http://www.example.com/green-parrots/" class="btn"> >> Green Parrots</a>';}
但这似乎不起作用。
有什么想法吗?
【问题讨论】:
-
单独检查每个。您正在使用的功能无法按照您发明的方式工作。查看文档:php.net/manual/en/function.stripos.php