![](/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.