September 2024
Intermediate to advanced
743 pages
27h 48m
English
In addition to the primitive data types from Table 15.2 in Section 15.3.1, PHP also has a complete object model, so you can use features such as visibility, abstract and final classes, and methods, as well as magic methods, interfaces, and cloning. But let’s skip that complexity for now and start with the basics.
A class is a collection of methods and properties and serves as a blueprint for mapping real objects. Listing 15.40 shows how a Book class is created by the class keyword. What follows is the list of the properties $title, $price, $author, and $isbn. Below, you’ll find the printDescription() method, which is declared like a function using the function keyword. Inside the method, ...
Read now
Unlock full access