PHP if statement is used to execute some code, if a condition is evaluated to true otherwise if the condition is evaluated to false, execute nothing, or execute some other code.

Figure - Flowchart of if Statement:


The following example will output "wish you a very happy birthday" if the current date is 01-10. Otherwise, it will output nothing. You can also use only if condition, if else is not required.

Example of a PHP Program to Demonstrate if Statement



if ($date=="01-10") { 
  echo "Wishing you a very Happy Birthday";