ankitweblogic logo
W e b t u t o r i a l s

Define PHP

PHP Installation


PHP Case Sensitivity

PHP Variable

PHP Echo & Print

PHP Operators

PHP Receiving Input

PHP Decision Making

PHP Loops

PHP Jumping Statement

PHP Image Gallery

PHP Arrays

PHP Date Functions

PHP String Functions

PHP Math Functions

PHP Functions

PHP Variable Scope

PHP Constant Variable

PHP Superglobals

PHP Form Validation

PHP Include Statement

PHP Filter

PHP File Handling

PHP File Upload

PHP Cookies

PHP Session

PHP Send Emails

PHP Captcha

PHP-MySQL Connectivity

PHP MySQL Select

PHP MySQL Insert

PHP MySQL Delete

PHP MySQL Update

Decision Making in PHP

You can use conditional statements in your code to make your decisions. PHP supports following decision making statements:
if statement - executes some code only if a specified condition is true.
if...else statement - use this statement if you want to execute a set of code when a condition is true and another if the condition is not true.
if...elseif statement - is used with the if...else statement to execute a set of code if one of several condition are true.
switch statement - is used if you want to select one of many blocks of code to be executed, use the Switch statement. The switch statement is used to avoid long blocks of if..elseif..else code.

Example 1: If condition. Example 2: Switch condition. Exercise Question:
$t = date("H");
if current time is less than 12 display good morning, if current time is less than 20 display Good Day, else print good nite.