I have a complex application I'm writing in PHP4 and want to be able to have any of the various objects that make it up instantiate a general-use object that will be available from within the scope of any method in any other object.
These general-use "helper" objects do things like help with forms or text and only need be instantiated on certain page calls but then I'd like to have that same object remain avaialable rather than making new instances elsewhere when needed.
I have tried making the object available in the global scope but that doesn't make it available in methods in other objects.
function load_helper( $classname, $data = NULL )
{
require_once( DIRECTORY_ROOT . 'helpers/' . $classname . '.class.php' );
global $$classname;
$$classname = new $classname( $data );
}
Is something like this possible?