【问题标题】:Cannot assign by reference to overloaded object无法通过引用重载对象进行分配
【发布时间】:2013-03-21 18:33:19
【问题描述】:

这是我的 wordpress 主题的一部分,它给了我最后一行代码的错误。 我在 PHP 5.4 上运行 wordpress 3.5.1

Fatal error: Cannot assign by reference to overloaded object in C:\server\htdocs\web\digitalnak\wp-content\themes\rework\framework\php\PeTheme\PeThemeGallery.php on line 234

这是代码

 $post =& get_post($id);
    if (!$post ) return $post;
    $null = null;
    if ($post->post_type != "gallery") return $null;

    $meta =& $this->master->meta->get($id,$post->post_type);
    $post->meta =& $meta;

【问题讨论】:

  • 哪些是第 234 行?你运行的是什么版本的PHP?你运行的主题是什么?什么版本的 Wordpress?
  • 234 是 $post->meta =& $meta ,我有 php 版本 5.4 和 wordpress 3.5.1
  • $post是什么对象?

标签: php wordpress object overloading


【解决方案1】:

没有看过任何东西——因此这可能根本不起作用——试试这个:

$post =& get_post($id);
if (!$post ) return $post;

$null = null;
if ($post->post_type != "gallery") return $null;

$meta =& $this->master->meta->get($id,$post->post_type);
$post->meta = $meta;

看起来您正在通过引用 ArrayAccess 对象来分配值。这在某些版本的 PHP 中不起作用。我无法判断这一点,但看起来这段代码非常频繁地使用传递引用,可能超出了必要。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多