Results 1 to 5 of 5

Thread: Classes

  1. #1

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Cool Classes

    Hello All!

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

    php Code:
    1. include ('./includes/vt_admin/vt_class/admin.php');
    2. $admin = new Admin($_SESSION['webmaster']);
    3. include ('./includes/vt_admin/vt_class/log.php');
    4. $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...

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Classes

    global $admin?

  3. #3

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: Classes

    Ill give it a try!

  4. #4

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: Classes

    Works well, I had tried that, ended up putting it in the wrong place.

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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();
        }

    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width