PDA

Click to See Complete Forum and Search --> : Classes


I_Love_My_Vans
May 23rd, 2008, 09:20 AM
Hello All!

So I am making the control panel to a projct for college, the control panel uses many classes...

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...

penagate
May 23rd, 2008, 11:57 AM
global $admin?

I_Love_My_Vans
May 23rd, 2008, 02:51 PM
Ill give it a try!

I_Love_My_Vans
May 23rd, 2008, 06:40 PM
Works well, I had tried that, ended up putting it in the wrong place.

visualAd
May 23rd, 2008, 07:28 PM
If using OOP to tackle the problem I tend to take the static approach stay away from global variables:


class Site
{
public static $admin;

public static function init()
{
self::$admin = new Admin();
}
}

class User
{
public function goArray()
{
Site::$admin->getPermissions();
}
}