Getting Site URL

Getting Site URL $domain = $_SERVER[‘SERVER_NAME’]; $domain = str_replace('www.', '', $domain); //Remove the leading www. if ($domain == 'somedomain.co.uk' || $domain == 'anothersite.net' || $domain == 'thirdsite.com' )

Read More

Detecting Name Of Page Include A File

//include_once('includes/my_include_file.php'); //Get the name of the file calling this include $calling_file = end(explode('/', $_SERVER[‘PHP_SELF’])); switch ($calling_file) { case 'some_file.php':

Read More

Site Root

You can’t do this in php: require_once ‘/s3_settings.php’; So instead do this: require_once($_SERVER[‘DOCUMENT_ROOT’] . ‘/s3_settings.php’);

Read More

Getting URL Arguments

Example GET URL http://www.somedomain.com/somedir/somepage.php?name_a=value_a&name_b=value_b&name_c=value_c Start with an '?', then separate other values with an '&' To read: if (!empty($_REQUEST[‘redirect_to’])) //Note that a value of zero will cause empty() to be true if (isset($_REQUEST[“source”])) //A value of zero will still give isset() being true so this is often the better choice then empty() echo $_REQUEST[“name_a”] . "<br/>"; […]

Read More