Check if the url contains a specific word and then displays

I have the following URL structure.

 example.com/items/something_something.

What will be the php code to verify that the url contains the word "items" and then displays specific divs?

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

thank

+4
source share
1 answer

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

+11
source

Source: https://habr.com/ru/post/1598915/


All Articles