12 Oct 2006
I am just playing around with PHP 5 for the first time (for a study project).
So I made a class out of some PHP 4 code I had and called the PHP page containing it.

Firefox said nothing. Nada. Safari at least said:

"Safari can’t open the page “http://localhost/elearning/testils/UserTask.php”. The error was: “lost network connection” (NSURLErrorDomain:-1005)"

It took me a while to find out what went wrong:
I used the static variable part wrongly.

Try calling this script:


class Test {
    public static $bla = "bla";



It should fail in the same way (that may depend on the Version of PHP 5, I don't know...).
The last line has to be


The first really crappy thing about PHP here is that you don't get any feedback. It took me over an hour of my time, guys! Tell me what I did wrong.

The second thing is that to print a static variable "bla" of the same class you're in, you would say (like above):


But if "bla" were non-static, it would have to be:


The dollar sign switches from the class/object designator to the variable name. Why? I bet there is a reason that could be nicely explained, but I also think I am not alone when it wasn't the first thing I tried...
# lastedited 20 Oct 2006
You are seeing a selection of all entries on this page. See all there are.