O'Reilly logo

PHP 7 Quick Scripting Reference, Second Edition by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Mikael Olsson 2016

Mikael Olsson, PHP 7 Quick Scripting Reference, 10.1007/978-1-4842-1922-5_22

22. Magic Methods

Mikael Olsson

(1)Hammarland, Finland

There are a number of methods that can be implemented in a class for the purpose of being called internally by the PHP engine. These are known as magic methods and they are easy to recognize because they all start with two underscores. Table 22-1 lists the magic methods that have been discussed so far.

Table 22-1. Magic Methods

Name

Description

__construct(...)

Called when creating a new instance.

__destruct()

Called when object has no references left.

__call($name, $array)

Called when invoking inaccessible methods in an object context.

__callStatic($name, $array)

Called when invoking inaccessible ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required