utexas_pjm: thank you! Your post helped me alot
That code is fine, but say I want the navi class to access other classes, such as "session" and "logger". I'd have to initialize the classes and then do:
$navi = new navi( $MySQL , $session , $logger );
right? This could get a bit messy if my "session" class also wants to access the "MySQL" and "logger" class, and so on.
I've came up with a solution that works:
class ifc0nfig
{
var $func = null;
var $smarty = null;
var $MySQL = null;
var $navi = null;
}
class navi
{
var $ifc0nfig = null;
function __construct( &$ifc0nfig )
{
$this->ifc0nfig =& $ifc0nfig;
}
}
and I initialize like so;
$ifc0nfig = new ifc0nfig( );
$ifc0nfig->func = new func( &$ifc0nfig );
$ifc0nfig->smarty = new Smarty( );
$ifc0nfig->MySQL = new MySQL( params );
$ifc0nfig->navi = new navi( &$ifc0nfig );
and then within a class, lets say the navi class, I can access the MySQL class with
$this->ifc0nfig->MySQL->some_method( );
Can anyone see anything wrong with this, any bad points etc?