【发布时间】:2019-03-23 01:32:32
【问题描述】:
如果当前 URL 包含某些单词,我想显示自定义内容。
到目前为止,如果 URL 仅包含单词“cart”,我可以使用下面的代码实现此目的。但是,我希望能够检查“博客”、“事件”和“新闻”等其他词。我该怎么办。
<?php $path = $_SERVER['REQUEST_URI'];
$find = 'cart';
$pos = strpos($path, $find);
if ($pos !== false && strstr($_SERVER['HTTP_REFERER'], 'path/to/site') !== false) :
?>
Custom content
<?php else: ?>
【问题讨论】:
标签: php regex drupal-7 preg-match-all preg-grep