/** * Include a script, unless it has caused a fatal error. * Using this function allows handling fatal errors that are thrown by the included php scripts * * @param string $file The full path of the php file to include * @param string $include_variation Which variation or adaptation of php's include() function to use (include,include_once,include_if, include_once_if, require ...) * @param array List of global variables to set */ function IncludeScript($file, $include_variation = 'include_once', $globals = array()) { $exists = file_exists($file); //check to see if it exists $include_variation = str_replace('_if', '', $include_variation, $has_if); if ($has_if && !$exists) { return; } //check for fatal errors if (\gp\tool\Output::FatalNotice('include', $file)) { return false; } //set global variables foreach ($globals as $global) { global ${$global}; } switch ($include_variation) { case 'include': $return = (include $file); break; case 'include_once': $return = (include_once $file); break; case 'require': $return = (require $file); break; case 'require_once': $return = (require_once $file); break; } \gp\tool\Output::PopCatchable(); return $return; }