how can i obtain name of the class instance from its inside
Posted: Fri Apr 08, 2005 12:18 am
how can i obtain name of the class instance from its inside.
i searched the web, but i couldn't find any real way.
i just found some programming ways.
1.
2.
3.
if need somthing like get_class but not for class name, for instance name.
any idea will be appreciate.
Code: Select all
class TTest
{
function instance_name()
{
echo "instance name : $instance_name";
}
}
$test=new TTest();
$text->instance_name();Code: Select all
result :
instance name : testi just found some programming ways.
1.
Code: Select all
$test=new TTest('test'); //'test' is name of instanceCode: Select all
$test=new TTest();
$test->instance_name='test';Code: Select all
$instance='test';
$$instance=new TTest($instance);any idea will be appreciate.