Why does this give me parse error? going crazy over here..
I have this file right:
function start_connection() {
global $config['db_host'];
}
Parse error: parse error, expecting ','' or
';'' in functions.php on line 5
when declaring the global variable do not include the array key, so:
global $config;
this will provide access to all key => value pairs within $config array within the function start_connection().
You can't global an array within a variable. Only the variable.
just do:
function start_connection() {
global $config;
echo $config['db_host'];
}
You can only use global variables, but not a specific value of a array.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.