停止在PHP中使用“global”
config.php
$config = array();$config['site_name'] = 'Site Name';$config['base_path'] = '/home/docs/public_html/'; $config['libraries_path'] = $config['base_path'] . '/libraries';//etc...
function.php
global $config
$config
global
?
global
function conversion($Exec, $Param = array(), $Log = '') { global $config; $cmd = $config['phppath'] . ' ' . $config['base_path'] . '/' . $Exec; foreach ($Param as $s) { $cmd .= ' ' . $s; } }
key
value
$config
$sql = "SELECT * from settings";$rsc = $db->Execute($sql);if ( $rsc ) { while(!$rsc->EOF) { $field = $rsc->fields['setting_options']; $config[$field] = $rsc->fields['setting_values']; @$rsc->MoveNext(); }}
vars
$db
, $language
global
global
global
<-- WTF!!
global $db
global
?
define
vars
$db
$db
P.S.
犯罪嫌疑人X
有只小跳蛙