News Feed
Sections




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

Joshua Thompson's Blog:
Prototype-based programming in PHP
November 09, 2006 @ 11:13:47

Exploration in a language is always a good thing and, in this new post to his blog, Joshua Thompson approaches a method of programming familiar to Javascript users - Prototype-based programming.

The basic idea is that functions can be added to classes dynamically. In Javascript functions can be added to a static class (using prototype) and it will be added to all instances of the class, or they can be added to a specific instance and only be added to that instance.

The rest of the post is all about the code - a Prototype class that sets up the __get, __call, __set magic functions and a prototype() method and isCallable method (to check if a function exists). In his example, he creates three test classes that he adds functions to, including one that inherits from one of the other test classes (and not just the Prototype class).

In the end, he uses it to call his custom "fun" methods, outputting various results based on the contents passed in.

0 comments voice your opinion now!
prototype programming get set call tutorial codesample prototype programming get set call tutorial codesample


blog comments powered by Disqus

Similar Posts

WorkingSoftware.com.au: Configuring PHP4 and PHP5 to run concurrently on FreeBSD

Dave Gardner's Blog: Setting up continuous integration for PHP using Hudson and Phing

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 6)

Zend Developer Zone: AJAX Chat Part Tutorial 6 : Updating the User List

PHPClasses.org: PHP Image Nudity Filter


Community Events





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


laravel version release library install voicesoftheelephpant security composer opinion language symfony update framework series introduction podcast interview community tool package

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