Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Location
    Earth
    Posts
    305
    Thanks
    27
    Thanked 2 Times in 2 Posts

    else if quick question

    Is it ok to use an if/elseif without the last else?

    I have some code that I only want to do something based on 2 things and then I don't want it to do anything but move on.

    for example

    PHP Code:
    <?php

    if ($r_status == 0){
      echo 
    "this stuff"; }
    else if (
    $r_status == 1){
      
    ehco "this other stuff"; }

    ?>
    $r_status can = 2 & 3 a well but I don't want anything to print, just want it to move on

    I have it up and working, just wondering if this is an appropriate way of doing it. Can't find anything online about not using the last else

  • #2
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    Yes, that's fine.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •