Late Static Binding

 <?php

class Base
{
    protected static $name = "Yahoo by self";
    public function show()
    {
        echo self::$name . "<br>";
        echo static::$name;
    }
}
class Derived extends Base
{
    protected static $name = "Hello World by static";
}
$test = new Derived();
$test->show();

//  OUTPUT:
//Yahoo by self
// Hello World by static
?>

Comments

Popular posts from this blog

Logical_Operators

SubQuery with EXISTS and NOT EXISTS in PHP

Get Functions