本文整理汇总了PHP中F3::global方法的典型用法代码示例。如果您正苦于以下问题:PHP F3::global方法的具体用法?PHP F3::global怎么用?PHP F3::global使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类F3
的用法示例。
在下文中一共展示了F3::global方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
/**
Kickstart the framework
@public
**/
public static function start()
{
// Get PHP settings
$_ini = ini_get_all(NULL, FALSE);
$_level = E_ALL ^ E_NOTICE;
ini_set('error_reporting', $_level);
// Intercept errors and send output to browser
set_error_handler(function ($_errno, $_errstr) {
// Bypass if error suppression (@) is enabled
if (error_reporting()) {
F3::error($_errstr, 500, debug_backtrace(FALSE));
}
}, $_level);
// Do the same for PHP exceptions
set_exception_handler(function ($_xcpt) {
if (!count($_xcpt->getTrace())) {
// Translate exception trace
$_trace = debug_backtrace(FALSE);
$_arg = $_trace[0]['args'][0];
$_trace = array(array('file' => $_arg->getFile(), 'line' => $_arg->getLine(), 'function' => '{main}', 'args' => array()));
} else {
$_trace = $_xcpt->getTrace();
}
F3::error($_xcpt->getMessage(), $_xcpt->getCode(), $_trace);
return;
// PHP aborts at this point
});
if (isset(self::$global)) {
// Multiple framework instances not allowed
trigger_error(self::TEXT_Instance);
return;
}
// Hydrate framework variables
$_base = self::fixSlashes(realpath('.')) . '/';
self::$global = array('AUTOLOAD' => $_base . 'autoload/', 'BASE' => $_base, 'DEBUG' => FALSE, 'ENCODING' => 'UTF-8', 'FONTS' => $_base, 'GUI' => $_base, 'IMPORTS' => $_base, 'LOADED' => array(), 'LOGS' => $_base . 'logs/', 'MAXSIZE' => self::bytes($_ini['post_max_size']), 'QUIET' => FALSE, 'RELEASE' => FALSE, 'SYNC' => self::SYNC_Default, 'TIME' => time(), 'THROTTLE' => 0, 'VERSION' => self::TEXT_Version);
if (!in_array('zlib', get_loaded_extensions())) {
// ZLib required
self::$global['CONTEXT'] = 'zlib';
trigger_error(self::TEXT_PHPExt);
return;
}
// Create convenience containers for PHP globals
foreach (explode('|', self::PHP_Globals) as $_var) {
// Sync framework and PHP globals
self::$global[$_var] =& $GLOBALS['_' . $_var];
if ($_ini['magic_quotes_gpc'] && preg_match('/^[GPCR]/', $_var)) {
// Corrective action on PHP magic quotes
array_walk_recursive(self::$global[$_var], function (&$_val) {
$_val = stripslashes($_val);
});
}
}
// Use plain old output buffering as default
$_handler = NULL;
if (PHP_SAPI == 'cli') {
// Command line: Parse GET variables in URL, if any
preg_match_all('/[\\?&]([^=]+)=([^&$]*)/', $_SERVER['REQUEST_URI'], $_matches, PREG_SET_ORDER);
foreach ($_matches as $_match) {
$_REQUEST[$_match[1]] = $_match[2];
$_GET[$_match[1]] = $_match[2];
}
// Custom server name
$_SERVER['SERVER_NAME'] = strtolower($_SERVER['COMPUTERNAME']);
// Convert URI to human-readable string
self::mock('GET ' . $_SERVER['argv'][1]);
} elseif (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('/gzip|deflate/', $_SERVER['HTTP_ACCEPT_ENCODING']) && !$_ini['zlib.output_compression'] && function_exists('apache_get_modules') && in_array('mod_deflate', apache_get_modules())) {
// Use a conservative compression level
ini_set('zlib.output_compression_level', self::GZIP_Compress);
$_handler = 'ob_gzhandler';
}
ob_start($_handler);
// Initialize profiler
self::$global['PROFILE']['MEMORY']['start'] = memory_get_usage();
// Initialize autoload stack
spl_autoload_register('self::autoLoad');
}