If Homepage Statement

Published September 16th 2009
Filed under PHP

In PHP you can use an If Statement to display something on your homepage but something different on the rest of your pages. The search box on Let-Go.net is only displayed only on the homepage but not elsewhere on the site. Below is the code used to do this:

<?php
$uri = $_SERVER['REQUEST_URI'];
if ($uri == "/") {
echo "This is the homepage";
} else {
echo "This is not the homepage";
}
?>

You can change the echos to a line of code or replace them with a PHP include.