可以说我有这个代码:
<?php
class hello {
var $greeting = "hello";
function hello(){
echo $this->greeting;
return;
}
}
$hello1 = new hello;
$hello2 = new hello;
$hello4 = new hello;
?>
我如何让它回显实例化对象的所有名称(如果可能,它们各自的类),以便它回显(可能在数组中)“hello1 => hello,hello2 => hello,hello4 => hello”。
如果这是不可能的,有没有办法从类中告诉实例的名称,比如 echo instance_name($this); 会让我“hello1”。谢谢。