Skip to content

Instantly share code, notes, and snippets.

@nicksheffield
Created September 22, 2011 04:11
Show Gist options
  • Save nicksheffield/1234012 to your computer and use it in GitHub Desktop.
Save nicksheffield/1234012 to your computer and use it in GitHub Desktop.
Testing changes on a live php site without disrupting users
<?php
# dogs is the text every other user will see.
# "cats" is what the developer sees...
# This way, only the developer can see changes, and if they want to show the client, they can.
?>
<h1>Heading!</h1>
<p>This is some text about <?php if(!isset($_GET['dev'])): ?>dogs<?php else: ?>cats<?php endif; ?>
<?php
# useful for applying new classes too
?>
<p<?php if(isset($_GET['dev'])) echo ' class="canine"'; ?>>This is some text about dogs</p>
<?php
# or to make it easy, set it up as a constant, for example..
define('DEVMODE',isset($_GET['dev']));
?>
<h1><?php if(DEVMODE): ?>New<?php else: ?>Old<?php endif; ?> Heading</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment