Another useful predefined variables that you will use frequently is $_SERVER[PHP_SELF']. At zebra0.com there are a number of games in many languages.
The code for everyone of these games is
<?php include($_SERVER[DOCUMENT_ROOT]."/Hello/include/game.php"); ?>Nothing else! The included file, game.php uses PHP_SELF to find the URL for the page and can then break that apart to find out which language the page is and which game so that it can insert the correct flash movie with the correct parameters for that language.
$thispage= $_SERVER['PHP_SELF']; // /English/puzzle/farm.php
$thispage=str_replace('//','/',$thispage); //replace double slash with a single slash
$section=explode('/',$thispage); //create array 1=English, 2=puzzle, 3=farm
$language=$section[1]; //English
$game=$section[2]; //puzzle
$activity=str_replace(".php","",$section[3]); //farm.php becomes farm
//code to generate the rest of the page with the Flash movie and parameters.
A new game can be tested in one language and then the page for the new game, such as farm.php can be copied to all of the other languages. This makes it very easy to add new games and also to add new languages.
In addition to the function include, there is also a function require. The two functions are identical except that with include, if the page is not found it will continue without it. If require is used, the page will fail if the required file is not found.
Please note that an additional factor that facilitates maintaining a web site of this size is that each language has the exact same directory structure and file names.
In fact, this book is created using many include files, thus making it easy to add pages and rearrange the order of the pages.