Introduction
Since PHP is a dynamically typed language where types are associated with data instead of variables, it's essential to understand the role that types play in the data operations landscape. In the previous chapter, we learned about the available data types in PHP, their usage with variables and typecasting. We also practiced adding and removing items from an array and went through type conversion and alternative approaches to assigning string data to a variable with heredoc
and nowdoc
.
In this chapter, we will discuss control statements and why they are essential, and we'll explore what PHP has to offer in this area. Control statements are the most important feature of any programming language. In simple terms, they help to control the flow of a program. Branching and looping are the main types of control structures that help to decide program flow. They also help to craft recursive loops for complex program flows.
Branching allows us to follow the correct...