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

Ajax Insert Records in Database Tutorial in PHP

SubQuery with EXISTS and NOT EXISTS in PHP

Submitting HTML Form data in JSON File (without MySql Database) in PHP