duanreng3439
2014-04-29 22:09
浏览 60
已采纳

Debian PHP 5.4.27与Ubuntu PHP 5.4.16

Well, I'm transferring a little web server from one computer to other, on the 'other' computer I cannot a more updated version of PHP,

I just have to add my files through ssh and that's all, when I load my webpage it says explicitly:

The error is showing on a Debian with PHP 5.4.27 squeeze, the webserver comes from an Ubuntu with PHP 5.4.16 oneiric

Parse error: syntax error, unexpected '[' in ~directory~ on line 38

This is the line 38.

$VALUE=$DB->query("a nice sentence")->fetch()[0];

So, i was pretty surprised because PDO was accepted since PHP 5.1, so, i look deeper and i found the possible error, you can't simply do ->fetch()[0], you must separate it in order to be "processed",

However, I have transport this server with this information before, so i really don't know if it's something on the configuration of PHP or maybe the version by itself 5.4.X? You guys know any hint? As I said, i can't just install other updated version of PHP5, what do you recommend?

Have a nice night.

Edit: updated to the issue on the PHP 5.4 now

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

  • dongye1942 2014-04-30 13:07
    最佳回答

    Apparently, the error was solved by JUST changing the first issue line (the other hundreds of codes that had that wasn't necessary to change, what i believe to be a little weird).

    $VALUE = $DB->query("a nice sentence")->fetch()->offset(0);
    
    评论
    解决 无用
    打赏 举报
查看更多回答(2条)

相关推荐 更多相似问题