【问题标题】:PHP Fatal error: Can't use method return value in write context [duplicate]PHP致命错误:无法在写入上下文中使用方法返回值[重复]
【发布时间】:2016-01-05 20:34:09
【问题描述】:
if (isset( $xml->xpath('/lfm/artist/image[@size="extralarge"]')[0])) {

正在使用 PHP 5.3 版(在服务器老兄切换到 5.3 之前是 5.7)。

在顶部的行中,我们收到此错误:

PHP Fatal error:  Can't use method return value in write context

我已经阅读了几篇文章,但没有什么明显的想法 - 可能是没有看到树林透过树木的情况。

除了切换回 5.7 之外,关于如何摆脱错误的任何建议?

【问题讨论】:

  • php5.4中引入的数组解引用

标签: php php-5.3


【解决方案1】:

为了与 PHP

$elements = $xml->xpath('/lfm/artist/image[@size="extralarge"]');
if (isset($elements[0])) {

如果您有兴趣了解更多信息,请查看https://wiki.php.net/rfc/functionarraydereferencing

【讨论】:

    猜你喜欢
    • 2016-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-06
    • 2011-10-12
    • 2012-08-21
    • 2015-06-14
    • 2012-06-20
    相关资源
    最近更新 更多