|
-
May 23rd, 2008, 09:20 AM
#1
Thread Starter
Frenzied Member
Classes
Hello All!
So I am making the control panel to a projct for college, the control panel uses many classes...
php Code:
include ('./includes/vt_admin/vt_class/admin.php');
$admin = new Admin($_SESSION['webmaster']);
include ('./includes/vt_admin/vt_class/log.php');
$log = new Log();
But can I access the $admin class from the $log class, do I have to do anything special to the code to allow this?
I ask because at the moment I am trying to access the $admin class form inside a function within the $log class and it returns absolutely nothing.
Any Ideas?
Ask if you need more code to work from...
-
May 23rd, 2008, 11:57 AM
#2
-
May 23rd, 2008, 02:51 PM
#3
Thread Starter
Frenzied Member
-
May 23rd, 2008, 06:40 PM
#4
Thread Starter
Frenzied Member
Re: Classes
Works well, I had tried that, ended up putting it in the wrong place.
-
May 23rd, 2008, 07:28 PM
#5
Re: Classes
If using OOP to tackle the problem I tend to take the static approach stay away from global variables:
PHP Code:
class Site { public static $admin;
public static function init() { self::$admin = new Admin(); } }
class User { public function goArray() { Site::$admin->getPermissions(); } }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|