解析错误:语法错误,PHP 5.3出现意外"[" [英] Parse error: syntax error, unexpected '[' with php 5.3

查看:147
本文介绍了解析错误:语法错误,PHP 5.3出现意外"["的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的脚本在xampp上运行正常.现在,我尝试将其上传到服务器上,但是直接吐出了一个

My script is working really fine on my xampp. Now I tried to upload it on the server, but it spat directly a

解析错误:语法错误,意外的'['

Parse error: syntax error, unexpected '['

在我的脸上. :(

它嘲笑的那一行是这样的:

The line which its mocking about is this one:

    $item = $xml->xpath($path)[0];

我不知道出什么问题了.我试图查看php 5.3 changelog,但未找到任何有关它的信息. (因为我在服务器上安装了5.3,而在xampp上安装了旧版本)

And I have no idea what is wrong. I tried to look on the php 5.3 changelog but did not found anything about it. (Because I have 5.3 on the server, and on xampp its an olderversion)

整个代码块如下所示:

$path = '//item[@id="'.$id.'"]';
if ($xml->xpath($path)) {
    $item = $xml->xpath($path)[0];
} else {
    die('<p class="error">Script Error: Code 101 - Please contact administrator</p>');
}

我非常感谢您的帮助,我无法与[google联系,也不知道它可能来自哪里,因为在xampp上可以正常工作

I am thankful for any help, I cannot seach [ with google and have no idea where it could come from, since on xampp its working fine

推荐答案

尝试一下 $item = $xml->xpath($path);
$item = $item[0];

Try this $item = $xml->xpath($path);
$item = $item[0];

这篇关于解析错误:语法错误,PHP 5.3出现意外"["的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆