2015-07-21 72 views
4

我有以下url結構。檢查url是否包含某個字,然後顯示

example.com/items/something_something. 

什麼是php代碼來檢查url包含單詞「items」,然後顯示某些div?

<?php if() { ?> <!--Check if url contains the word "items" --> 
    Show this 
<?php } else { ?> 
    Don't show this 
<?php } ?> 

感謝

回答

10

if(strpos($_SERVER['REQUEST_URI'], 'items') !== false){

相關問題