Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

TutsPlus.com:
PHP Control Structures and Loops: if, else, for, foreach, while and More
Oct 15, 2018 @ 12:42:13

On the TutsPlus.com site today they're "getting back to basics" with a tutorial targeted at those just learning the PHP language. In this latest tutorial, they focus on control structures and loops such as if, else, for, foreach, while and more.

In simple terms, a control structure allows you to control the flow of code execution in your application. Generally, a program is executed sequentially, line by line, and a control structure allows you to alter that flow, usually depending on certain conditions.

Control structures are core features of the PHP language that allow your script to respond differently to different inputs or situations. This could allow your script to give different responses based on user input, file contents, or some other data.

They start with a flowchart showing the basic idea behind how flow control structures work and provide a more "real world" example of a user login. It then goes through each of the control structure types, providing a simple explanation of what it does, where it's useful and code examples of it in action.

tagged: control structure language tutorial beginner

Link: https://code.tutsplus.com/tutorials/php-control-structures-and-loops--cms-31999