PHP If Question, how to do a then statement if it's more php code

Discussion in 'PHP' started by phaze3131, May 18, 2009.

  1. #1
    Hey guys probably a newby question.

    I have a simple php if like this:


    <?php
    if (is_front_page()) {

    But the stuff I want to execute here is more php code, which confuses me should I do an Echo for each line of php code or something else?


    }
    ?>


    Thank you so much!
     
    phaze3131, May 18, 2009 IP
  2. phaze3131

    phaze3131 Well-Known Member

    Messages:
    538
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    140
    #2
    i'm such a newb!

    I just put it inside a big if block

    <?php if (is_front_page()): ?>

    DO STUFF HERE

    <?php endif; ?>
     
    phaze3131, May 18, 2009 IP
  3. AdscendJeremy

    AdscendJeremy Peon

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    btw, you don't have to use the alternate IF syntax. you can do this:

    <? if (is_front_page()) { ?>

    do stuff

    <? } ?>
     
    AdscendJeremy, May 18, 2009 IP
  4. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I realize this is an old (1 day) thread, but to execute more PHP:

    
    if($EXPRESSION)
    {
    // CODE HERE
    }
    
    PHP:
    Do not close the PHP tags:

    
    <? if (is_front_page()) { ?>
    
    do stuff
    
    <? } ?>
    
    PHP:
     
    NatalicWolf, May 19, 2009 IP
  5. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #5
    That is funny syntax.
     
    Kaizoku, May 20, 2009 IP
  6. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    NatalicWolf said it in one. why close tags if it's more php code? :p
     
    szalinski, May 22, 2009 IP