The way I do it is with a switch:
<?php
switch($id)
{
default: // makes this the default switch
case index: //if $id = index
{
//(index stuff here)
}
case stuff: // if $id = stuff
{
//(stuff's stuff here)
}
case foo:
{
//(foo's stuff here)
}
}
?>
When you point your browser to the PHP file, let's say index.php, it'll load up case index. Any other value besides the defined ones point to the default case, which is index. If you had index.php?id=foo, it'll point to foo, if it were stuff, it'll point to stuff. You can put this practically anywhere in your file. I usually put it in a table where the content loads.