Hello,
I'm developing web aplication and I have some questions how to use object
to get what I want.
I have init.php file wher I prepare everything (DB,Auth....) so I have
several objects created.
Then I have index.php which gets all requests and load requested modules.
This modules have to use DB, Auth, Smarty ......
init.php <
$db = new DB.....
$auth = new Auth....
$tpl = new Smarty...
------------------------
index.php <
$mod = loadModule('mod1');
$mod->getData().....
function loadModule($mod) {
require $mod.'.php';
$m =& new $mod;
return $m
}
------------------------
mod1.php <
Class mod1 {
// some property
function getData() {
// here I want to use $db or $auth
// right now I have only solution
// to use global $db
}
}
I hope this code explains what my needs. What is the best way. Or am I
doing all wrong. Maybe some other ideas. What about global.
I don't like to use $GLOBALS, because I want to use those object like in
pear documentation, so without some strange coding, because this modules
will be developed from public. I also tried to pass those objects with
reference into Class when it was generated. But then I have to use
$this->db etc.
I search for this on the web but I couldn't find any good answers or
projects.
--
Best regards,
Uros
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php