你好我有這種結構的內部多維數組的價值觀:獲取另一個陣列
$GLOBALS['config'] = array(
'mysql' => array(
'host' => 'localhost',
'username' => 'root',
'password' => 'root',
'dbname' => 'database'
),
'session' => array(
'session_name' => 'user'
),
'remember' => array(
'cookie_name' => 'hash',
'cookie_expiry' => 604800
),
'folder' => array(
'root' => 'backend',
'header' => 'head',
'views' => 'views'
),
'database' => array(
'names' => 'utf8mb4',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'driver' => 'pdo'
),
'url' => array(
'base_url' => 'http://www.example.com/backend/',
'document_root' => $_SERVER['DOCUMENT_ROOT'] . "/backend"
),
'languages' => array(
'english' => 'en',
'german' => 'de',
'greek' => 'gr'
),
'headers' => array(
'404' => 'HTTP/1.0 404 Not Found',
'401' => 'HTTP/1.0 401 Unauthorized',
'500' => 'HTTP/1.0 500 Internal Server Error',
'403' => 'HTTP/1.0 403 Forbidden'
),
'title' => array(
'login' => 'Admin Dashboard',
'register' => 'Admin Dashboard | User Registration',
)
);
,我想在url/BASE_URL是這樣
'base_url' => 'http://www.example.com/'.$GLOBALS['config']['folder']['root'].'/'
所以如果我改變文件夾我只有唯一的地方改名字,但我得到像語法錯誤:
Notice: Undefined index: config in C:\xampp-php56\htdocs\backend\core\init.php on line 31
可能什麼,我試圖做的?如果可能的話如何?
不能引用自己的數組定義 – billyonecan
內的數組的索引我怎麼能引用到該文件夾數組此URL陣列內的任何想法? – BRG
只需在定義陣列後設置它即可。 – billyonecan