From: [EMAIL PROTECTED] Operating system: Win2k PHP version: 4.2.3 PHP Bug Type: Unknown/Other Function Bug description: parentheses surrounding return()'s arguments do seem to matter
I'm using PHP 4.2.3 on Windows NT 5.0 build 2195 (win2k) along with Apache and stumbled across a strange behaviour regarding return() arguments in parentheses. Consider the following code: class Node { var $children; var $name; function Node($name) { $this->children = array(); $this->name = $name; } function &add($n) { $this->children[0] = $n; return($this->children[0]); # these () make a difference } } $t = new Node("top"); $node = new Node("foo"); $n = &$t->add($node); $n->name = "bar"; print $n->name; # output: "bar" print $t->children[0]->name; # output: "foo" The code is working as expected (i.e., both times "bar" is printed) when you remove the parentheses from the return call in the add method. According to the manual, parentheses in a return call shouldn't make a difference. -- Edit bug report at http://bugs.php.net/?id=20739&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20739&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20739&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20739&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20739&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20739&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20739&r=support Expected behavior: http://bugs.php.net/fix.php?id=20739&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20739&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20739&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20739&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20739&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20739&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20739&r=isapi