As I have read Static properties cannot be accessed through the object using the arrow operator ->.
The static properties can be accessed through the class name with the resolution operator.
In the following example, I am able to access the static method through the object using the arrow operator ->
.
class Foo {
public static $name="I am php";
public static function aStaticMethod() {
// ...
echo 'In Static method';
}
}
Foo::aStaticMethod();//output: In Static method
$obj = new Foo;
$obj->aStaticMethod();//output: In Static method
$obj->name;
output:
In Static methodIn Static method
But when try to access the variable $name through operator ->
it gives following error:
PHP Notice: Accessing static property Foo::$name as non static in /home/jdoodle.php on line 14
PHP Notice: Undefined property: Foo::$name in /home/jdoodle.php on line 14
Does php really support OOPs properly and what do you mean by Static properties cannot be accessed through the object using the arrow operator ->
?
Thanks