|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-11-30 16:00 UTC] iliaa@php.net
[2002-12-09 06:41 UTC] andi@php.net
[2002-12-09 07:14 UTC] sniper@php.net
[2003-08-15 06:23 UTC] ali@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 14:00:01 2025 UTC |
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.