News Feed
Sections




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

NETTUTS.com:
Deciphering Magic Methods in PHP
July 20, 2010 @ 13:27:44

Whether you're new to the language or to the more advanced features of it, you might find the magic methods a bit confusing at first. Thankfully, NETTUTS.com is here to help with this new tutorial on what they are and how to use them in your code.

PHP provides a number of 'magic' methods that allow you to do some pretty neat tricks in object oriented programming. These methods, identified by a two underscore prefix (__), function as interceptors that are automatically called when certain conditions are met. Magic methods provide some extremely useful functionality, and this tutorial will demonstrate each method's use.

They define a sample class so you can see them in context - a Device and a Battery. They cover constructors/destructors, get/set, isset/unset, toString, clone and more (including the callStatic that's only in the recent PHP 5.3 versions of the language).

0 comments voice your opinion now!
magic method tutorial introduction


blog comments powered by Disqus

Similar Posts

WebReference.com: XML and PHP Simplified - XML,PHP and the Database

DevShed: Using the Active Record Pattern with PHP and MySQL

Ibuildings techPortal: Learning PHP 5.3 by writing your own ORM

PHP-Coding-Practices.com: Composing Methods: Replace Temp With Query

Community News: Symfony Framework Makes Some Updates (v.0.6.2 and Content)


Community Events





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


deployment community conference series list symfony laravel interview code api voicesoftheelephpant introduction podcast tips threedevsandamaybe framework zendserver language release bugfix

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