php 检查 url 是否包含某个单词然后显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31543554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:30:18 来源:igfitidea点击:
Check if url contains certain word then display
提问by Steve Kim
I have following url structure.
我有以下网址结构。
example.com/items/something_something.
What would be php code to check that the url contains the word "items" then display certain divs?
什么是 php 代码来检查 url 是否包含单词“items”然后显示某些 div?
<?php if () { ?> <!--Check if url contains the word "items" -->
Show this
<?php } else { ?>
Don't show this
<?php } ?>
Thanks
谢谢
回答by Jessica
if(strpos($_SERVER['REQUEST_URI'], 'items') !== false){
if(strpos($_SERVER['REQUEST_URI'], 'items') !== false){