PHP if url contains

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

http://www.url.com/page?=short will display the word "Short"
http://www.url.com/page?=anyother_or_no_value will display the word "Not Short and Not Home"
http://www.url.com/page?=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.