PHP Late Static Binding:
A new feature called late static binding is introduced in PHP 5.3.0 which can be used to refer the called class.
The name late static binding is coined because of the static:: will no longer be resolved using the class where the method is defined.
Example:
<?php
class
One { public static function classIdentifier() { echo __CLASS__;}
public static function classtest() { self::classIdentifier();}
}
class
Two extends One { public static function classIdentifier() { echo __CLASS__;}
}
Two::classtest();
?>
Output:
One
Example:
<?php
class
One { public static function classIdentifier() { echo __CLASS__;}
public static function classtest() { static::classIdentifier();}
}
class
Two extends One { public static function classIdentifier() { echo __CLASS__;}
}
Two::classtest();
?>
Output:
Two
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.