//Difference Between self:: and static::
<?php
class A {
protected static $name = "Class A";
public static function getName() {
return self::$name; // Uses class A's property
}
public static function getNameStatic() {
return static::$name; // Uses the property from the child class
}
}
class B extends A {
protected static $name = "Class B";
}
echo B::getName(); // Output: Class A (Because of self::)
echo B::getNameStatic(); // Output: Class B (Because of static::)
?>