Simple testing on a live site

Ever wanted to make changes to a live site without disrupting it for visitors? Use isset() as a cloak of mystery…

As ever, I’ve been making some changes to my site WhenWillIBeSober.com (roadmap here), and I’ve been wanting to fiddle with things without disrupting the live site.

Normally you have two options on testing:

  1. Set up a duplicate install, make changes on that, then ship them over.
  2. Don’t do that, and hope that no one uses the site in moment when its broken.

Option 1 can be a lot of hassle, and Option 2 can cause your users a lot of hassle, so I implemented a very simple method: Option 3…

Simple add an

isset($_GET["test"])

statement to your code, and put all your changes inside it. This way, people visiting the page won’t see your changes, but you can check them out by adding

?test=1

onto the url.

So, the code I’ve used today is:

<?php if (isset($_GET["test"])) {
include 'php/graphs.php';
}
else { ?>
<h3>Watch this space!</strong>.</h3>
<p>Coming soon is an exciting graphs area...</p>
<?php } ?>

And my site changes are only visible to anyone who visits the url with the test variables – as you can see in the screenshot below. Happy testing people!

Image by Richard Anthony Morris. Thanks!

3 thoughts on “Simple testing on a live site

Leave a Reply

Your email address will not be published. Required fields are marked *