Blog de programación, errores, soluciones

Chose Language:
comments
Author: Admin/Publisher |finished | checked

PHP – Control structures

PHP provides various control structures, which are fundamental tools for directing the execution flow of your program. They allow you to make decisions based on certain conditions, repeat tasks, and organize your code effectively.

This is the full list of control structures we have in PHP

  • if
  • else
  • elseif/else if
  • while
  • do-while
  • for
  • foreach
  • break
  • continue
  • switch
  • match – match is a relative new control structure introduced in PHP 8
  • declare
  • return
  • require
  • include
  • require_once
  • include_once
  • goto (we are not going to see this one, the mayority of time if we use abuse of goto sentence we finish in a spagetti code, make the code harder to read and another bunch of problems)

I have divided the content into other articles; if we see it all together, it becomes too heavy to read at once.

This article will explain you if, else, elseif/else if and how to use the if inside a function
switch
For and foreach statements
while and do-while
On this article you could see what does require, include, require_once, include_once.
The match is a new control structure that you can use instead of switch and if
Category: en-php
Something wrong? If you found an error or mistake in the content you can contact me on Twitter | @luisg2249_luis.
Last 4 post in same category

Comments