PHP if url contains

<?php if(strpos($_SERVER['REQUEST_URI'], 'short') !== false):?> Short <?php elseif(strpos($_SERVER['REQUEST_URI'], 'home') !== false):?> Home <?php else: ?> Not Short and Not Home <?php endif; ?>
This will display three values based on a string in the URL ex: will display the word "Short" will display the word "Not Short and Not Home" will display the word "Home

1 Response

Thank you!

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.