Use of "lazy static bindings"

Source: Internet
Author: User

Code highlighting produced by Actipro Codehighlighter (freeware) http://www.codehighlighter.com/--> 1 <?phpclassParentbase {Static $property= ' Parent Value ';  Public Static functionrender () {returnSelf::$property; }}classDescendantextendsParentbase {Static $property= ' descendant Value ';}EchoDescendant::render (); Parent Value

In this example, the render () method uses the Self keyword, which refers to the Parentbase class instead of the descendant class. The final value of the $property cannot be accessed in the Parentbase::render () method. To solve this problem, you need to override the render () method in the subclass.

By introducing the lazy static binding feature, you can use the static scope keyword to access the properties of a class or the final value of a method.

Code highlighting produced by Actipro Codehighlighter (freeware) http://www.codehighlighter.com/--> 1 <?phpclassParentbase {Static $property= ' Parent Value ';  Public Static functionrender () {return Static::$property; }}classDescendantextendsParentbase {Static $property= ' descendant Value ';}EchoDescendant::render ();D escendant Value

Use of "lazy static bindings"

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.