I'm attempting to come up with the best way to use default variables and override them if a $_GET is passed via the URL. Right now, I only have two, but I'll be adding more as I develop the site. Is there a better way?
I'm using define to define the variable and isset to determine if a variable is set and is not NULL.
define("THEME", "atom");
define("VERSION", "1.00");
if(isset($_GET["theme"]))
{
$theme = $_GET["theme"];
} else
{
$theme = THEME;
}
if(isset($_GET["version"]))
{
$version = $_GET["version"];
} else
{
$version = VERSION;
}
UPDATE I decided on the following. I'm storing my site settings in settings.php:
$settings = array();
$settings['theme'] = 'default';
Then I include that file, use the ternary operator, and then define the variable:
include_once('settings.php');
$theme = (isset($_GET["theme"])) ? $_GET["theme"] : $settings['theme'];
define("THEME", $theme);