IF ELSE IN PHP
IF ELSE IN PHP
NESTED IF STATEMENT IN PHP
SWITCH STATEMENT IN PHP

In This Blog, you will learn about conditional statements in php like if, if-else, if-else-if, nested if statement and switch statement. Conditional statements are very important when creating php websites because we have to put our logic by using these conditional statements.

STATEMENT IN PHP

  • Statement is a smallest element of any programming language
  • Statement consists of commands given by a programmer to a computer
  • Statement can be an individual statement or a group of statements within curly braces
  • Statement usually ends with a semicolon
  • PHP script consists of a series of statements which are as follows:
    • An assignment
    • A function call
    • A conditional statement
    • An empty statement that does nothing

Conditional Control Structures In PHP

Control the flow of a program on execution or skip code based on certain criteria.

  • Conditional Control Structures are of two types:
  • if statement
    • If else
    • If else if (ladder)
    • Nested if
  • switch statement

if Statement in PHP

  • It is a common control structure
  • It contains an expression called as truth expression
  • The truth expression:
    • Can be a Boolean, variable, constant or an expression
    • Evaluates to true, false or NULL
    • If evaluates to true, following statements are executed
    • If evaluates to false or NULL, statements are not executed

if-else Statement in PHP

  • It is used along with if statement
  • It is executed when a specified condition is false
  • Else is optional.
  • It means if you don’t specify else no error will occur but no result will be displayed if a condition is false.

IF-ELSE-IF STATEMENT (LADDER) IN PHP

  • It is used along with if statement
  • It is an optional clause that allows testing alternative conditions

Nested if Statement In PHP

In PHP, an if statement within an if statement or an else statement is known as nested if statement

switch Statement In PHP

  • It is used as an alternative to a lengthy if…else construct
  • It consists of an expression that is compared to all possible case expressions listed in its body
  • On finding a match, it executes the block of code ignoring any further case lines
  • It uses a break statement to halt the execution of the switch statement and transfer the control to the code following switch.

Download Notes From the link given below.

https://www.mediafire.com/file/6wbzxt40frij0av/CONDITIONAL+STATEMENTS+IN+PHP.pptx/file

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *