The PHP language allows for both, a procedural and an object-oriented (OO) way of writing code. Whereas the procedural way is more of a remnant of initial versions of PHP, nothing really stops us from writing fully procedural applications even today. While both approaches have their advantages and disadvantages, the OO way is by far the most dominant one nowadays, the advantages of which are more evident in robust and modular applications, which are nearly impossible to work on with the procedural style.
Knowing the individual features of the PHP OO model is vital to understand, write, and debug modern applications. The magic methods are one of the more interesting and often mystic features of the PHP language. They are the predefined class methods that the PHP compiler executes under some event, such as object initialized, object destroyed, object converted...