A little php help please

If you're using PHP, then just echo it only if the URL matches:

Code:
<div>foo</div>

<?php if ($_SERVER['REQUEST_URI'] == 'http://example.com/example.html?querystring=value') : ?>
<div>bar</div>
<?php endif; ?>

<div>baz</div>

There's no need to include the div in the markup if it doesn't need to be displayed :)
 
Code:
<div>foo</div>

<?php if ($_GET['querystring'] == 'value'): ?>
<div>bar</div>
<?php endif; ?>

<div>baz</div>

Would be cleaner and better I reckon.

It might however give you a notice if you're using E_ALL for error reporting...

so maybe:

Code:
<div>foo</div>

<?php if (isset($_GET['querystring']) && $_GET['querystring'] == 'value'): ?>
<div>bar</div>
<?php endif; ?>

<div>baz</div>
 
Last edited:
Back
Top Bottom