http://codepad.viper-7.com/ezvlkQ
So, I’m trying to figure out:
...?php
$object = new A();
class A
{
static public $foo = 'bar';
function displayFoo()
{
echo $this->$foo;
}
}
A::displayFoo();
A->displayFoo();
?>
About this, how many errors can you find? Can you tell me what they are in real human terms? I can’t really interpret what is and what is not okay from the validator that codepad uses…
I’ve updated your code here http://codepad.viper-7.com/UaUE4g
Error 1:
This should read:
.. as it is static.
Error 2:
The method is an instance method
::is used for access to static methods.Error 3:
This is an error because
Ais undefined and if it was it should have read$A. This would be okay:.. as $object is an instance of class A.
Next step, consult the manual on the topic static.