PHP static extension binding simple example _ PHP Tutorial

Source: Internet
Author: User
Tags echo b
A simple example of PHP static Deferred binding. This new feature has not been used in simple PHP static latency binding examples, but it is not new. try it, now the inheritance of static classes facilitates the simple example of classA {protectedstatic $ def12345 PHP static latency binding

I have never used this new feature, but it is not new. try it. it is very convenient to inherit static classes.

Class {

Protected static $ def = '20140901 ';

Public static function test (){

Echo get_class (new static );

}

Public static function test2 (){

Echo static: $ def;

}

}

Class B extends {

Protected static $ def = '20140901 ';

}

Class C extends {

Protected static $ def = 'abcdef ';

}

Echo B: test ();

Echo'

';

Echo C: test ();

Echo'

';

Echo B: test2 ();

Echo'

';

Echo C: test2 ();

Echo'

';

Echo A: test ();

Echo'

';

Echo A: test2 ();

Echo'

';

// Output result

B

C

456789

Abcdef

A

123456

I have never used this new feature before, but it is not new. try it. now the inheritance of static classes is very convenient for class A {protected static $ def = '100...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.