[英]Cannot understand this php parser error
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 解析错误:解析错误,在第5行的functions.php中期望
','' or
';''
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(). 这将提供对函数start_connection()中$ config数组中所有key => value对的访问。
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. 您只能使用全局变量,而不能使用数组的特定值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.