Course Content
Module 1 — Discovering PHP
Understand what PHP is, set up a local environment and write your first script.
0/4
Module 3 — Functions, arrays and forms
Create functions, work with arrays and handle data coming from a form.
0/4
PHP for beginners

Conditions let your program make decisions. You test an expression, and depending on whether it is true or false, a different block of code runs.

Comparison operators

  • == equal to  /  === equal and of the same type.
  • != not equal to.
  • > greater than  /  < less than.
  • >= and <= greater/less than or equal to.

The if / else structure

  1. if tests a condition.
  2. elseif tests another condition if the first one is false.
  3. else runs when no condition is true.

For example: if $age >= 18 you display “Adult”, otherwise “Minor”. You can also combine conditions with && (and) and || (or).

Key point: be careful not to mix up = (assignment) and == (comparison). It is the classic beginner’s mistake.

Rejoignez-nous

Postdy Link Postdy Instagram TikTok YouTube Groupe informatique Postdy Community Instagram Community TikTok Community
Indicative prices, converted from the euro