SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Probably eating pie mitsubishi's Avatar
    Join Date
    Sep 2001
    Location
    England, UK
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A few things about objects

    Hi, just started to learn OO and I've managed to get my session management into a class. A couple of things though;
    Why can't session_start() be in the constructor? Is this something to do with the internal order PHP does things.

    Is there a better way of registering the object, session_register(this) doesn't work, so I use
    $sess->init('sess') and then
    function init($name){session_register($name);} inside the class definition.

    In the init function I also check if it's a new session and if so include() a browser check class and set variables based on the result, this works, but it seems a little dodgy, so is there any inherant problems with declaring a class within a class. Is this class available just as if it had been declared outside?

    Also a little moan - PHPCoder stops being able to track the includes (and so autocomplete on objects/functions stops) when you add eg include($basedir.'includes/common.php');

  2. #2
    Probably eating pie mitsubishi's Avatar
    Join Date
    Sep 2001
    Location
    England, UK
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just another thing, there probably isn't an answer, but.. rather than having lots of variables in the class I just have one array. Is there any advantage/disadvantage to this?


Bookmarks

Posting Permissions

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