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