Skip to content

is_safe_mode function for PHP

The following function will return TRUE if the server is running PHP in safe mode. It uses the function ini_get, which may be disabled. If ini_get is disabled then the function also returns TRUE since the assumption that any server disabling functions would probably also be running in safe mode.

function is_safe_mode()
/*    Returns true if PHP is in safe_mode.  Defaults to 'true' because
this will use ini_get which may be disabled.  If ini_get is disabled
then we are probably in safe_mode    */
{
$retval = true;

if (function_exists('ini_get'))
{
if (ini_get('safe_mode')==true)
{
$retval = true;
}
else
{
$retval = false;
}
}
else
{
$retval = true;
}

return $retval;
}
Published inProgramming

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *