Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5444 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81991 invoked by uid 1010); 13 Nov 2003 18:57:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 81964 invoked from network); 13 Nov 2003 18:57:46 -0000 Received: from unknown (HELO hemna.uh.nu) (209.172.92.6) by pb1.pair.com with SMTP; 13 Nov 2003 18:57:46 -0000 Received: from hemna.uh.nu (river.hemna.uh.nu [127.0.0.1]) by hemna.uh.nu (8.12.8/8.12.8) with ESMTP id hAD12kBc010816; Wed, 12 Nov 2003 17:02:46 -0800 Received: (from waboring@localhost) by hemna.uh.nu (8.12.8/8.12.8/Submit) id hAD12j2H010814; Wed, 12 Nov 2003 17:02:45 -0800 X-Authentication-Warning: hemna.uh.nu: waboring set sender to waboring@3gstech.com using -f To: internals@lists.php.net Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-ID: <1068685365.19565.5.camel@hemna.uh.nu> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 12 Nov 2003 17:02:45 -0800 Subject: php5 method return reference error? From: waboring@3gstech.com (Walt Boring) Howdy, I'm playing with php5 (from cvs), and came accross a strange error that doesn't happen with php4. Maybe someone can shed some light on this for me? I get the error "Fatal error: Only variables or references can be returned by reference in /home/waboring/devel/html/test.php on line 11" Here is the php code _buildOBJ(); } function &_buildOBJ() { $obj = new foo(); $obj->test = 'worked'; return $obj; } } $bar = new bar; $foo = $bar->get(); echo $foo->test; ?> This doesn't happen in php4. This seems to go away if I change the bar::get() method to function &get() { $obj =& $this->_buildOBJ(); return $obj; } This seems like a bug to me, since both cases the return value is a reference of an object? Thanks Walt