Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP classes do not work.

Options
  • 08-06-2009 8:23pm
    #1
    Registered Users Posts: 1,061 ✭✭✭


    I've uploaded my working site (tested with MAMP and PHP5) to Blacknight Solutions' web space. Everything works apart from PHP classes.

    I can do this much:
    class TestClass{}
    ... and it's fine,

    but as soon as I put anything in the class, like:
    class TestClass
    {
    private $testvariable;
    }

    ... it JUST DIES and the page won't load beyond the point that the class was included or required, or whatever!

    I can try a constructor, like this:
    class TestClass
    {
    public function TestClass(){

    }
    }

    ... again IT DIES at that point.

    Help????????


Comments

  • Registered Users Posts: 3,568 ✭✭✭ethernet


    Does it work if you initialise $testvariable?

    If it's PHP5, the constructor tends to look like:

    [php]public function __construct()
    {
    // foo
    }[/php]Not sure if the PHP4-style constructor is supported but worth a try.

    BTW, what happens when you try to instantiate it? Any errors/warnings?


  • Registered Users Posts: 1,061 ✭✭✭MontgomeryClift


    Would you believe it? - I logged in just now, changed nothing, and it worked. Very weird!

    I'm using the constructor without the double underscore, with PHP5. It's working at the moment. Initializing the variable didn't help. I could leave out variables completely and have nothing but an empty function, and it still didn't work. Until now, when suddenly it did!

    Thanks for your help.


Advertisement