Let's say I have this code:
<?php
class hello {
var $greeting = "hello";
function hello(){
echo $this->greeting;
return;
}
}
$hello1 = new hello;
$hello2 = new hello;
$hello4 = new hello;
?>
How can I make an echo of all the names of created objects (and, if possible, their corresponding class) so that it echoes (possibly in an array) "hello1 => hello, hello2 => hello, hello4 => hello".
If this is not possible, is it possible to specify an instance name from a class, something like echo instance_name ($ this); I would get "hello1". Thanks.
Yifan source
share