Home > Backend Development > PHP Tutorial > PHP delayed static bindingLate Static Bindings_PHP tutorial

PHP delayed static bindingLate Static Bindings_PHP tutorial

WBOY
Release: 2016-07-13 17:35:11
Original
1037 people have browsed it

Take a look at the Late Static Bindings of PHP5.3 and briefly translate it
Late Static Bindings is a new feature added in PHP5.3. In Pinyin, it is an expression that was originally fixed in the definition stage.
or variables are changed during the execution phase. For example, when a subclass inherits the static expression of the parent class, its value cannot be changed. You do not want to see this situation when there is

class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
self::who( :) );//Input A
?>
But now I want it to output B, so this feature can be achieved using Late Static Bindings
class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
static::who(); // Late Static Bindings
}
}
class B extends A { 
  public static function who() {
     echo __CLASS__;
  }
} 
B::test();//Output B
?>




http://www.bkjia.com/PHPjc/508358.html

www.bkjia.com
true

http: //www.bkjia.com/PHPjc/508358.html

Took a look at the Late Static Bindings of PHP5.3, and briefly translated Late Static Bindings in PHP5.3 The new features added, in terms of Pinyin, are expressions that were originally fixed in the definition stage...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template