Re: Recursive Object Troubles

From: Date: Tue, 26 Aug 2003 00:09:24 +0000
Subject: Re: Recursive Object Troubles
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-160693@lists.php.net to get a copy of this message
>I am building a recursive Menu object. Inside each menu item there is an >array which should allow me to add submenu items and so on. I am having >trouble, though, with getting the submenus to stay. They are >disappearing as I go along. Without really going through your code (sorry) I would hazard a guess that you are assigning by value, rather than by reference - by default, the '=' operator in PHP passes a copy of an object or variable, rather than a reference to it. The 'new' language construct does this as well. So do functions, when they return values. All of this is very annoying and requires you to liberally sprinkle your code with the '&' that denotes passing-by-reference. --------------------------------------------------------------------- michal migurski- contact info and pgp key: sf/ca http://mike.teczno.com/contact.html

« previous php.general (#160693) next »