Show content based on URL Parameter

<?php if(isset($_GET['option1'])){ ?> Do option1 stuff here <?php } > <?php if(isset($_GET['option2'])){ ?> Do option2 stuff here <?php } >
If used in a PHP template, this snippet will only display that content if "option1" or "option2" is present in the url.

For example, www.mysite.com/?option1 will display the content from the "option1" block.

This is good for testing code that has multiple options for a client to approve. It can also block test code from interfering with live content if you need to edit something on production.

Be the first to 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.