Learn Before
Concept

PHP Conditional Statements

When writing code, it's very common to want to take multiple actions depending on the situation. To accomplish this, you can utilize conditional statements in your code.

The following conditional statements are available in PHP:

  • If a condition is true, the if statement performs some code; if it is false.
  • if...else statement executes some code; and if it is true.
  • if...elseif...else statement executes multiple codes for more than two circumstances.
  • Switch statements are used to choose which of numerous code blocks to execute.
<?php $t = date("H"); if ($t < "20") { echo "Welcome to 1cademy.com!"; } ?>

0

2

Updated 2023-10-12

References


Tags

Object-Oriented Programming (OOP) Languages

Related