2013-03-21 21 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中不起作用。我無法判斷這一點,但它看起來好像這個代碼使用非常嚴重的傳遞引用,可能超過必要。