note 10041 deleted from Classes and Objects by jimw

From: Date: Thu, 11 Jan 2001 03:24:38 +0000
Subject: note 10041 deleted from Classes and Objects by jimw
Groups: php.notes 
Request: Send a blank email to php-notes+get-9634@lists.php.net to get a copy of this message
# Editor's Note # Do not do this! # When you call an object's constructor from # within the constructor, you are creating an # infinite loop. An attempt to instantiate the # object results in another attempt to instantiate # the object, which results in another ... Has anyone else encountered a problem when you call an object's constructor from within the same constructor? I have an object with one of it's member variables acting as a pointer to another object of the same type. When I try to initialize it within the constructor, I just get what I guess is a trashed response from the server (with no clue as to what the error was, causing hours wasted away in trying to hunt it down. Here is a code example: class Object { . public Object() { . this.object = new Object(); } This causes everything to blow up.

« previous php.notes (#9634) next »