2013-03-21 60 views
0

这是我wordpress主题的一部分,它给了我最后一行代码的错误。 荫在PHP 5.4无法通过引用分配过载对象

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 

运行的WordPress 3.5.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; 
+0

其中哪些是234行?你运行的是哪个版本的PHP?你正在运行的主题是什么?什么版本的WordPress的? – andrewsi 2013-03-21 18:34:38

+0

234是$ post-> meta =&$ meta,我有php版本5.4和wordpress 3.5.1 – 2013-03-21 18:36:52

+0

'$ post'是什么类型的对象? – 2013-04-18 15:46:26

回答

0

,而不必看着任何东西 - 作为这可能等无法工作 - 试试这个:

$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中不起作用。我无法判断这一点,但它看起来好像这个代码使用非常严重的传递引用,可能超过必要。