HTML in PHP if statement

Discussion in 'Programming' started by passingTime, Sep 16, 2011.

  1. #1
    Is there any way to use HTML in php if statements?

    Like for example:

    <html>

    <?php
    if (1=1) {
    <input type "text" id="test" />
    }

    else {
    <input type="submit" id="submit" value="submit" />
    }

    ?>
    </html>
     
    Solved! View solution.
    passingTime, Sep 16, 2011 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    <html>

    <?php
    if (1=1) {
    ?>
    <input type "text" id="test" />
    <?php
    }

    else {
    ?>
    <input type="submit" id="submit" value="submit" />
    <?php
    }

    ?>
    </html>

    hope it helps
     
    kmap, Sep 16, 2011 IP
  3. passingTime

    passingTime Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Nice one thanks a lot and + rep
     
    passingTime, Sep 16, 2011 IP
  4. #4
    The other way is
    
    
    <?php
    echo '<html>';
     
    if (1=1) {
    echo '<input type "text" id="test" />';
    }
    
    else {
    echo '<input type="submit" id="submit" value="submit" />';
    }
    
    ?>
    </html> 
    PHP:
     
    Rukbat, Sep 16, 2011 IP