本文整理汇总了PHP中Solar::cleanGlobals方法的典型用法代码示例。如果您正苦于以下问题:PHP Solar::cleanGlobals方法的具体用法?PHP Solar::cleanGlobals怎么用?PHP Solar::cleanGlobals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solar
的用法示例。
在下文中一共展示了Solar::cleanGlobals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCleanGlobals
/**
*
* Test -- Cleans the global scope of all variables that are found in other super-globals.
*
*/
public function testCleanGlobals()
{
$GLOBALS['foo'] = 'bar';
$GLOBALS['baz'] = 'dib';
$_POST['foo'] = 'bar';
Solar::cleanGlobals();
$this->assertTrue(empty($GLOBALS['foo']));
$this->assertFalse(empty($GLOBALS['baz']));
}
示例2: start
/**
*
* Starts Solar: loads configuration values and and sets up the environment.
*
* Note that this method is overloaded; you can pass in different
* value types for the $config parameter.
*
* * `null|false` -- This will not load any new configuration values;
* you will get only the default [[Solar::$config]] array values defined
* in the Solar class.
*
* * `string` -- The string is treated as a path to a Solar.config.php
* file; the return value from that file will be used for [[Solar_Config::load()]].
*
* * `array` -- This will use the passed array for the [[Solar_Config::load()]]
* values.
*
* * `object` -- The passed object will be cast as an array, and those
* values will be used for [[Solar_Config::load()]].
*
* Here are some examples of starting with alternative configuration parameters:
*
* {{code: php
* require_once 'Solar.php';
*
* // don't load any config values at all
* Solar::start();
*
* // point to a config file (which returns an array)
* Solar::start('/path/to/another/config.php');
*
* // use an array as the config source
* $config = array(
* 'Solar' => array(
* 'ini_set' => array(
* 'error_reporting' => E_ALL,
* ),
* ),
* );
* Solar::start($config);
*
* // use an object as the config source
* $config = new StdClass;
* $config->Solar = array(
* 'ini_set' => array(
* 'error_reporting' => E_ALL,
* ),
* );
* Solar::start($config);
* }}
*
* @param mixed $config The configuration source value.
*
* @return void
*
* @see Solar::cleanGlobals()
*
*/
public static function start($config = null)
{
// don't re-start if we're already running.
if (Solar::$_status) {
return;
}
// make sure these classes are loaded
$list = array('Base', 'Class', 'Config', 'File');
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Solar';
foreach ($list as $name) {
// don't use the autoloader when checking for existence
if (!class_exists('Solar_' . $name, false)) {
require $dir . DIRECTORY_SEPARATOR . "{$name}.php";
}
}
// register autoloader
spl_autoload_register(array('Solar_Class', 'autoload'));
// clear out registered globals
if (ini_get('register_globals')) {
Solar::cleanGlobals();
}
// load config values
Solar_Config::load($config);
// make sure we have the Solar arch-class configs
$arch_config = Solar_Config::get('Solar');
if (!$arch_config) {
Solar_Config::set('Solar', null, Solar::$_Solar);
} else {
Solar_Config::set('Solar', null, array_merge(Solar::$_Solar, (array) $arch_config));
}
// set the system directory
Solar::$system = Solar_Config::get('Solar', 'system');
// process ini settings from config file
$settings = Solar_Config::get('Solar', 'ini_set', array());
foreach ($settings as $key => $val) {
ini_set($key, $val);
}
// user-defined registry entries
$register = Solar_Config::get('Solar', 'registry_set', array());
foreach ($register as $name => $list) {
// make sure we have the class-name and a config
$list = array_pad((array) $list, 2, null);
//.........这里部分代码省略.........