RE: [PHP4BETA] Class member variable bug???
| From: | Brad Handy | Date: | Fri, 21 Jan 2000 19:06:51 +0000 |
| Subject: | RE: [PHP4BETA] Class member variable bug??? | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-9342@lists.php.net to get a copy of this message | ||
It's not a bug in PHP it's how classes are handled. Here's what's
happening:
>$mn_1=new
>MenuNode("Main1","http://main1.com");
>echo "<hr>";
>$mn_2=new
>MenuNode("Sub2","http://sub2.main.com");
>$mn_1->addBranch($mn_2); <-- Makes a COPY on $mn_2 at this point.
$mn_2->branch_rows == 0 that's why you're getting you're count misreported.
>echo "<hr>";
>$mn_3=new
>MenuNode("Sub3","http://sub3.main.com");
>$mn_1->addBranch($mn_3); <-- Same here with $mn_3. $mn_3->branch_rows
== 0.
It's making a copy at the point you pass it into $mn_1->addBranch(). You'll
have to change the order of assignment to get it to work.
--Brad Handy