Jump to content

getting an object's variable?


genericnumber1

Recommended Posts

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]
<?php
class 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.
Link to comment
https://forums.phpfreaks.com/topic/31030-getting-an-objects-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.