News Feed
Sections




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

Lorna Mitchell:
9 Magic Methods in PHP
December 11, 2012 @ 12:18:49

Lorna Mitchell has a new post showing nine of the magic methods that are included in PHP by default (like __construct, __get and __set) including a few you may not have used before.

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 includes details (and some code samples) for these methods:

  • __construct
  • __destruct
  • __get
  • __set
  • __call
  • __sleep
  • __wakeup
  • __clone
  • __toString

You can find out about these and a few others in this page of the PHP manual.

0 comments voice your opinion now!
magic methods oop introduction beginner tutorial


blog comments powered by Disqus

Similar Posts

PHPBuilder.com: Intro to PHP

MaltBlue.com: Zend Form Mastery with Zend Config - Part 4 Configuring Zend Validators

Pádraic Brady's Blog: RESTful Web Services with Zend Framework

Joshua Eichorn's Blog: Slides from azPHP presentation of PEAR: An Introduction

DevShed: Using the Observer Design Pattern with Static Data in PHP 5


Community Events





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


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

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