© Gunnard Engebreth, Satej Kumar Sahu 2023
G. Engebreth, S. K. SahuPHP 8 Basicshttps://doi.org/10.1007/978-1-4842-8082-9_3

3. Functions, Classes, and Traits

Gunnard Engebreth1   and Satej Kumar Sahu2
(1)
Madison, WI, USA
(2)
Bangalore, India
 

So far, you have been using PHP for simple top-down scripting.

In this chapter, you will learn how to declare and use classes and functions (including class definitions, visibility, inheritance, and traits). Also, object-oriented programming (OOP) will be introduced and explained.

The real power of PHP comes with the ability to declare and use classes and functions. As a quick overview, classes are (as you saw in the last chapter) definitions for objects to use when being created. The class definitions then turn into ...

Get PHP 8 Basics: For Programming and Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.