News Feed
Sections
News Archive


Community Events






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


feed this:

C7Y:
Late Static Binding a practical example
0 comments :: posted Tuesday February 12, 2008 @ 15:52:36
voice your opinion now!

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.

tagged with: late static binding tutorial example code beer


DevShed:
PHP 5 and Polymorphism
0 comments :: posted Tuesday March 07, 2006 @ 07:19:08
voice your opinion now!
From DevShed, there's a more advanced tutorial that might interest PHP developers out there looking for more info on "polymorphism" for their apps.

This article explains what polymorphism is and how it applies to object oriented design in particular. It also explains the pros and cons of polymorphism when working with certain versions of PHP.

They start with a definition on the topic that doesn't seem to help much: "The occurrence of different forms, stages, or types in individual organisms or in organisms of the same species, independent of sexual variations." They do, however, follow that with what it means to programming: "...an interface or base class without regard to an object's concrete class." They also include a simple example (no code, that's later).

With that concept in place, they move to the next step - working with the example to create code that can be used as a reference point. They talk about using a switch to make the script respond differently to different inputs and the lack of "late binding" support in PHP5.

tagged with: php php5 polymorphism late binding switch php php5 polymorphism late binding switch


database pecl zendframework ajax code book releases application security PHP5 PEAR package framework zend cakephp developer conference release mysql job

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