Getting object variable name within the class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I would like to get the name of the object variable a class is represented
by within the class. So forexample

Class myclass
{
public function somefunction()
{
$thisclass = //whatever I need to do to get the name of the
//current object in this example should return foo
}
}

$foo = NEW myclass();

the need is as I want to use classes over multiple scripts (I want them to be alive when making an AJAX callback. And as classes talk to each other I can't pass objects to them as they don't serialize but if another class stores the variable name of the object then I can access the class. right now I got a workaround with making a property objname and create the class with 

$foo = NEW myclass();
$foo->objname = "$foo";

So now I can pass that to some other class with 

   $otherclass->linkedobj = $this->objname; // which is a string and will serialize properly

and then in the other class do something like

    EVAL($this->linkedobj . '->somepoproperty = "Hello world"';);

Is ther an easier way that allows me to get the objectname inside the class

TIA

Martin


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux