Home Tutorial Php Phpoop PHP Late Static Binding

 
 

Share on Google+Share on Google+
PHP Late Static Binding
Posted on: March 2, 2010 at 12:00 AM
Advertisement
In this current PHP tutorial Section, we will study about late static binding in PHP, what is late static binding, how to use late static binding among classes, what are the uses of it in PHP etc.

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

Advertisement

Related Tags for PHP Late Static Binding:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 2, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com