www.webdeveloper.com
Results 1 to 5 of 5

Thread: abstract classes and session_start

  1. #1
    Join Date
    Sep 2010
    Posts
    62
    It looks like you are requiring an abstract class and when the session starts, something is trying to create an instance of the abstract class. It isn't possible to create an instance of an abstract class directly, so you get the error. If you want to use an abstract class, create a child class of the abstract class and create an instance of the child class.
    Last edited by qjensen; 12-17-2010 at 09:38 AM. Reason: first explanation was way too involved :)
    Quint Jensen
    Web Developer
    Scaled Solutions

  2. #2
    Join Date
    Dec 2010
    Posts
    5

    abstract classes and session_start

    Something like:

    require_once('./classes.class.AbstractClass.php');

    session_start()


    gives the error;

    "cannot instantiate abstract class AbstractClass ......"

    What is the mechanism invloved here, please?

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,326
    Sounds like something in the code is trying to instantiate an abstract class (duh! ). So, look for something in the code (including in the included file) that does "new AbstractClass()". (You can only create objects from any concrete child classes of an abstract class, not the abstract class itself.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Dec 2010
    Posts
    5

    thanks but.

    Thank you both for your replies but I didn't phrase my question very well. These (or similar) are the first 2 lines of the code.

    It seems as if session_start() is trying to instantiate the class. If I remove this it goes on OK. What I really need to know is why session_start() should be behaving like this as I have session variables to pass to the next page..

  5. #5
    Join Date
    Dec 2010
    Posts
    5

    Duh!!

    Just realised why!! Thanks for replying.

    It wasn't an abstract class to start with but I've just subclassed it. Forgot to remove the constructor!!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles