News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

C7Y:
Late Static Binding a practical example
February 12, 2008 @ 15:52:36

Sean Coates has posted a new article today about one of the features that will be included in the next major release of PHP (5.3) - late static bindings.

Late Static Binding (LSB) is a topic that's been brought up numerous times in the past three years in various PHP development discussion circles (and we're finally getting it in PHP 5.3)'"but what does it really do, and why should you care? Here's a simple practical example of how it can greatly simplify your code's design.

He shows its usefulness in an example of how it works, letting classes/objects access static methods, constants and properties of inherited classes (besides their own). His example (using beer, of course) shows how an extended class (Ale) can reference the constant (NAME) in the parent class (Beer). Thanks to a new keyword in PHP 5.3 - "static::" - helps define the difference even clearer.

Check out the rest of the article for a more practical usage too.

0 comments voice your opinion now!
late static binding tutorial example beer


blog comments powered by Disqus

Similar Posts

Michael Nitschinger's Blog: A primer on PHP exceptions

Matthew Turland's Blog: Building PHP-GTK with Cairo Support on Ubuntu Jaunty

NetTuts.com: Create your First Tiny MVC Boilerplate with PHP

SitePoint PHP Blog: Arbitrary Precision and Big Numbers in PHP

PHPBuilder.com: Remote objects and Zend_Amf


Community Events

Don't see your event here?
Let us know!


api series version release library introduction language interview xdebug unittest laravel extension framework podcast voicesoftheelephpant community install php7 example opinion

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework