Here's my problem. I wrote a class that gets all the logged in users information it goes a little something like this <?php class user { var $username = ""; function user() { $this->set_user_info(); } function set_user_info(){ $this->username = "myusername"; } } $user_obj = new user(); ?> Code (markup): What I would like to be able to do. I have about 6 other classes that all do different things but are all dependent on the user class variables. Example class email { function send_email() { $to = "to@to.com"; $from = "from@from.com" $message = "this email was sent by $user_obj->username"; mail(......... } } Code (markup): What I would like to know is, how can I make the variables from the user class accessible to all my classes. What would be the best way. Right now I am calling global $user_obj; in all the functions that use the user class variables. Would it be better to make the other classes extend the user class or is there an easier method for this that I am unaware of! Thanks
you can try class email { global $user_obj; function send_email() { $to = "to@to.com"; $from = "from@from.com" $message = "this email was sent by $user_obj->username"; mail(......... } } PHP: