![](/img/trans.png)
[英]WordPress Events Calendar PHP not working on Godaddy server, but works in WAMP localhost
[英]populating php array variable is not working in godaddy server(php version 5.3.24) works perfectly in localhost
我正在尝试使用xml文件创建一个数组。 但是当我在服务器(php版本5.3.24)中运行代码时出现错误。 但是这在localhost中完美运行(php版本5.3.5)
解析错误:语法错误,第28行/home/content/61/10253461/html/crm/xmas/src.php中的意外'['
第28行是$ allowed [$ i] =(int)$ a-> attributes()[1]; 在以下代码中
function parcexml(){
$xml=simplexml_load_file("emaillist.xml");
$allowed=array();
$fname=array();
$femail=array();
$f1=array();
$f2=array();
$i=0;
foreach($xml->email as $a) {
$allowed[$i]=(int)$a->attributes()[1];
$fname[$i]=$a->attributes()[0];
$femail[$i]=$xml->children()[$i];
$i++;
}
}
请指明任何解决方案。
将其更改为:
function parcexml(){
$xml=simplexml_load_file("emaillist.xml");
$allowed=array();
$fname=array();
$femail=array();
$f1=array();
$f2=array();
$i=0;
foreach($xml->email as $a) {
$temp=(int)$a->attributes();
$allowed[$i]=$temp[1];
$fname[$i]=$temp[0];
$temp=$xml->children();
$femail[$i]=$temp[$i];
$i++;
}
}
所以在你的场景中这样做......
代替
$fname[$i]=$a->attributes()[0];
喜欢
$v = $a->attributes();
$fname[$i] = $v[0];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.