PHP OOP late static binding

PHP late static binding is used to access static properties of derived class using the method of base of class.

class Account{
	public static $name="Aman";	
	public function show(){
		echo static::$name;
	}
}

class User extends Account{
	public static $name="Rama";	
}

$user = new User();
$user->show();

 

© 2016 - 2022, All Rights are Reserved.