Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP classes do not work.

  • 08-06-2009 08:23PM
    #1
    Posts: 1,064 ✭✭✭


    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, Registered Users 2, Paid Member Posts: 3,519 ✭✭✭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?


  • Posts: 1,064 ✭✭✭ [Deleted User]


    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