1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What does <?php endif; ?> mean ?

Discussion in 'PHP' started by zipdrive, Jul 22, 2010.

  1. #1
    <?php endif; ?> is there a lots of places in wordpress
    what does it instruct/mean in the program ?
    SEMrush
     
    zipdrive, Jul 22, 2010 IP
    SEMrush
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Its does exactly what it says it ends the if, it tell the php parser; that the if (...): closes when endif; is declared.

    Example:

    <?php
    
    //start if statement...
    if ($username == "danx10") :
    
    //execute following code...
    echo "Hello ". $username;
    
    //end/close the if statement...
    endif;
    
    ?>
    PHP:
    As you can see from the above example it will execute everything between if(...): up until endif;
     
    Last edited: Jul 22, 2010
    danx10, Jul 22, 2010 IP
  3. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Check out here. It's used a lot in Wordpress because of the amount of HTML - it makes it easier to distinguish what blocks of code are ending rather than the ambiguous curly brace (which could be closing any block).
     
    Deacalion, Jul 22, 2010 IP
  4. caciocode

    caciocode Peon

    Messages:
    65
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    caciocode, Jul 23, 2010 IP
  5. arpit13

    arpit13 Active Member

    Messages:
    285
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    78
    Digital Goods:
    1
    #5
    i think it is an alternative of { }
     
    arpit13, Jul 24, 2010 IP