Close Menu
    Facebook X (Twitter) Instagram
    Oixiesoft
    • Home
    • Services
      • WordPress Malware Removal
      • Fix WordPress Errors
      • WordPress Website Development
    • Articles
    • Contact
    Oixiesoft
    Home»Tutorial»PHP»PHP if else Statements
    PHP

    PHP if else Statements

    Editorial StaffBy Editorial StaffNo Comments2 Mins Read
    Share
    Facebook Twitter LinkedIn Pinterest Email

    PHP if…else…elseif Statements

    The PHP if-else statements are used to make decisions based on distinct conditions.
    PHP keeps different types of decision-making conditions:

    • if statement
    • if…else statement
    • if…else if….else statement
    • switch statement

    PHP – The if Statement

    The body of the if statement performs some piece of code only if a specified condition is true.
    Syntax

    if(condition){
        // Code to be executed here
    }
    

    Example

    $x=15;
    $y=15;
    if($a==$b)
    {
    echo"successful";
    }
    

    The if…else Statement

    The if….else statement is used where the if the condition is not true then the else statement is executed.

    Syntax

    if(condition){
        // Code to be executed if condition is true
    } else{
        // Code to be executed if condition is false
    }
    

    Example

    $x=15;
    $y=15;
    if($a==$b)
    {
    echo"successfuly executed";
    }else
    {
    echo"loss";
    }
    

    PHP – The if…elseif….else Statement

    The if…elseif…else is a special statement to execute when multiple conditions are true.

    if(condition1){
        // Code to be executed if condition1 is true
    } elseif(condition2){
        // Code to be executed if the condition1 is false and condition2 is true
    } else{
        // Code to be executed if both condition1 and condition2 are false
    }
    

    Example

    $x=15;
    $y=15;
    $z=15;
    if($x > $y and $x > $z)
    {
    echo"x is biggest.";
    }
    elseif($y > $x and $y > $z)
    {
    echo"y is biggest";
    }
    elseif($z > $x and $z > $y)
    {
    echo" c is biggest";
    }
    else
    {
    echo"x=y=z";
    }
    
    Share. Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Tumblr Email
    Editorial Staff

    Related Posts

    CodeIgniter vs Laravel: A Detailed Side-by-Side Comparison

    Python Arrays

    Python Lambda

    PHP
    • PHP Comments
    • PHP if else Statements
    • The PHP switch Statement
    • PHP Functions
    • PHP for Loop
    • PHP Arrays
    • PHP Include Files
    • PHP Date() and Time() Function
    • PHP Forms Tutorial
    Services
    • Web Development
    • Mobile Application Development
    • WordPress Malware Removal Service
    • Website Design
    • WordPress Development
    • Magento Development
    • Shopify Development
    • SEO Services
    Blog
    • How to Fix the Error Establishing a Database Connection
    • Ping List WordPress
    • How To Fix Japanese Keyword Hack
    • How to remove Malware from WordPress
    Hire Developers
    • Hire WordPress Developer
    • Hire Shopify Developer
    Contact Info
    • Oixiesoft Technologies
      A-40, Block A, I thum Tower, Sector 62, Noida
    • [email protected]
    • Privacy Policy
    • About Us
    • Contact Us
    © 2025 OixieSoft Technologies

    Type above and press Enter to search. Press Esc to cancel.