Is there a function in php
that will return any instance of class available in memory?
Its direct complement would be class_exists
.
if( class_exists($className)){
$className = get_class($instance); // returns well.. you know.
}
// imaginary functions
instance_exists($className);
get_instance($className); // returns any instance it can find.
I don't have a case scenario were it can be useful. But it can find use in applications which provide some form of plugin system where plugins just implement interfaces and have the application just shift between implementations.