genericnumber1 Posted December 17, 2006 Share Posted December 17, 2006 Is there a way to get the variable name of the current instance of an object?I know it can be done by something like this...[code=php:0]<?phpclass foo { public $instanceVar; public function __construct($var){ $this->instanceVar = $var; }}$bar = new foo('bar');echo $bar->instanceVar;?>[/code]but is there some other way? like... a function that can be called inside the object? It's not critical that I know, just something that's made me curious. Quote Link to comment Share on other sites More sharing options...
trq Posted December 17, 2006 Share Posted December 17, 2006 [quote]but is there some other way?[/quote]Nope. Why would you need it? It doesn't exist within the class, that is what $this is for. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted December 18, 2006 Author Share Posted December 18, 2006 in case it needed to be passed to a different class perhaps? :X Oh well it's cleaner to pass it by reference outside the class anyways. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.