简体   繁体   English

填充php数组变量不适用于godaddy服务器(php版本5.3.24)在localhost中完美运行

[英]populating php array variable is not working in godaddy server(php version 5.3.24) works perfectly in localhost

I am trying to create an array by using xml file. 我正在尝试使用xml文件创建一个数组。 but when i run the code in server (php version 5.3.24) am getting an error. 但是当我在服务器(php版本5.3.24)中运行代码时出现错误。 But tihis is working perfectly in localhost (php version 5.3.5) 但是这在localhost中完美运行(php版本5.3.5)

Parse error: syntax error, unexpected '[' in /home/content/61/10253461/html/crm/xmas/src.php on line 28 解析错误:语法错误,第28行/home/content/61/10253461/html/crm/xmas/src.php中的意外'['

the 28th line is $allowed[$i]=(int)$a->attributes()[1]; 第28行是$ allowed [$ i] =(int)$ a-> attributes()[1]; in the following code 在以下代码中

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++;
}
}

please specify any solution. 请指明任何解决方案。

Change it to: 将其更改为:

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++;
}
}

Function array deferencing is available only from PHP 5.4.0 函数数组引用仅在PHP 5.4.0中可用

So on your scenario do like this... 所以在你的场景中这样做......

Instead of 代替

$fname[$i]=$a->attributes()[0];

Do like 喜欢

$v = $a->attributes();
$fname[$i] = $v[0];

Source

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WordPress活动日历PHP在Godaddy服务器上不起作用,但在WAMP本地主机中起作用 - WordPress Events Calendar PHP not working on Godaddy server, but works in WAMP localhost JSON响应在PHP版本5.3.24中不起作用 - JSON response is not working in PHP version 5.3.24 PHP图片上传可在localhost上运行,但不能在GoDaddy服务器上运行 - PHP picture upload works on localhost but not on GoDaddy server php function 验证令牌在 localhost 中有效,但在 GoDaddy 服务器上无效 - php function verify token works in localhost but not on GoDaddy server PHP - file_get_contents() 在 localhost 但在实时服务器上完美运行 - PHP - file_get_contents() works perfectly on localhost but on live server PHP重定向或cookie,不适用于Godaddy,但适用于localhost - PHP Redirects, or cookies, not working on Godaddy, but working on localhost PHP Bootstrap可以在localhost上完美运行,但不能在VPS上运行 - PHP Bootstrap working perfectly on localhost but not working on VPS php 数组代码在本地主机上工作但在服务器上不工作 - php array code working on localhost but not working on the server PHP App在localhost上完美运行,在任何Web服务器上完全失败,并出现一些奇怪的错误 - PHP App works perfectly on localhost and fails completely on any web server with some strange errors 站点在localhost上完美运行,但在服务器上运行不正常 - Site works perfectly on localhost, but not on server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM