News Feed
Sections




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

Think Vitamin:
9 Magic Methods for PHP
June 07, 2010 @ 13:58:41

For those just getting started with PHP and wondering what these "magic methods" are all about (and they can be a little confusing for someone not used to the language), Lorna Mitchell has a new tutorial posted to the Think Vitamin blog on just that topic.

The "magic" methods are ones with special names, starting with two underscores, which denote methods which will be triggered in response to particular PHP events. That might sound slightly automagical but actually it's pretty straightforward, we already saw an example of this in the last post, where we used a constructor - so we'll use this as our first example.

She talks about nine of these magic functions including:

  • __get/__set for variable handling
  • __sleep/__wakeup for serializing data
  • __call/__callStatic for methods in a class
  • __construct/__destruct for making and destroying classes
0 comments voice your opinion now!
magic method tutorial oop


blog comments powered by Disqus

Similar Posts

PHPBuilder.com: PHP Development on the Facebook Platform: Building Your First App

Community News: Sara Golemon & Christopher Jones - First Day Summaries of php|works

PHPBuilder.com: Creating an Online Survey - Part 2

VXTIndia Blog: How to setup your new VPS Ubuntu server

MaltBlue.com: \Zend\Db\Sql - Creating Joins and Unions with Ease


Community Events

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


configure opinion project interview example language list api framework laravel part2 symfony application introduction podcast composer yii2 community series php7

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