4. Functions
Overview
By the end of this chapter, you will be able to work with built-in functions; create user-defined functions; and write anonymous functions.
Introduction
When writing software, we often run into situations where we need to do a specific task in different places within the application that we are building. Without thinking about it, it can be easy to fall into the habit of rewriting the same code over and over again, causing code repetition and making it harder to debug errors when they show up. However, as with all other programming languages, PHP gives you the ability to structure reusable code in what is known as a function, which is also sometimes referred to as a method. These two terms will be used interchangeably ...
Get The PHP Workshop 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.