Re: How to find the object name in a class?

From: Date: Mon, 23 Apr 2001 23:51:23 +0000
Subject: Re: How to find the object name in a class?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49960@lists.php.net to get a copy of this message
*sigh* I'm thinking so too ;( Doh! However, I have at least a usable hack around. In the constructor of your class, add: function Class ($object_name) { global $pge; $pge = $object_name; } Then when you use create a new object of that type you must use: $objectname = new Class('objectname'); Then in your code you just use ${$pge}-> to refer to it. Sucks, doesn't it? -- Plutarck Should be working on something... ...but forgot what it was. ""Boget, Chris"" <Chris.Boget@wild.net> wrote in message news:4040BBE81A9AD411BD27009027887A7C042CA1@tiger.wild.net... > > So is there ANY way to get the name of the object in PHP code without > > knowing the name of the object ahead of time? > > I went through this exact thing not too long ago with an error class > I wrote. Unfortunately, there is no way to know. What you can do, > however, is do a check to see if that object exists before you access > the variable. Other than that, I think you're outta luck. :/ > > Chris >

« previous php.general (#49960) next »