#24745 [Com]: return ($val) is broken for references
| From: | no dot spam at forme dot pt | Date: | Fri, 08 Aug 2003 12:56:28 +0000 |
| Subject: | #24745 [Com]: return ($val) is broken for references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-45579@lists.php.net to get a copy of this message | ||
ID: 24745
Comment by: no dot spam at forme dot pt
Reported By: vma1 at abv dot bg
Status: Bogus
Bug Type: Zend Engine 2 problem
Operating System: Slackware Linux 9.0
PHP Version: 5CVS-2003-07-21 (dev)
New Comment:
http://pt.php.net/return
statement: "Note: Note that since return() (...), the parentheses
surrounding its arguments are not required (...) it doesn't matter one
way or the other."
in example above, return ($val) or return $val seems to matter.
Previous Comments:
------------------------------------------------------------------------
[2003-07-22 02:25:50] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Yup, this is expected.
------------------------------------------------------------------------
[2003-07-21 19:48:06] vma1 at abv dot bg
Description:
------------
"return ($val);" does not work in a function that returns a reference.
"return $val;" is OK.
Reproduce code:
---------------
class lala
{
var $val;
function lala ()
{
$this->val = 0;
}
function &get_val ()
{
$inf = 88;
$this->val = $inf;
return ($inf);
}
}
$obj = new lala;
$vvv = &$obj->get_val ();
Actual result:
--------------
Fatal error: Only variables or references can be returned by reference
in /usr/local/apache/site/htdocs/bug.php on line 15
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24745&edit=1