Results 1 to 5 of 5

Thread: Here's an easy one for you...

  1. #1
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default Here's an easy one for you...

    What is the point of doing this:

    PHP Code:
    <?php ?>
    at the very end of a source code? I have seen several php pages that end with that, something like:

    Code:
    <html>
    <head>
    <title>Words</title>
    </head>
    
    <body>
    <? php 
    code stuff here
    ?>
    html stuff here
    <img src= "letsputinapic.jpg">
    
    </body>
    </html>
    <?php } ?>
    What is the point?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #2
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    THey are closing something like an if,else,switch,for,whatever.Here is an example.
    PHP Code:
    <?php
    if($_POST['password'] == 'secret password'){
    ?>
    Super secret Information
    <?php
    }
    ?>

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    So, why the need for the closing and opening ?> <?php then? Shouldn't the statements be closed before the other information is parsed to/from the server? Or is it like a "catch all" for incase they forgot to close it earlier?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by BLiZZaRD
    What is the point of doing this:

    PHP Code:
    <?php ?>
    at the very end of a source code?
    On it's own, there is no point (and should raise a syntax error). However, code blocks can span raw output. For example,

    PHP Code:
    <?php
    if (condition) {
    ?>
    Some text...
    <?php
    }
    ?>
    "Some text..." will only be output if condition is true.

    Mike

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    OHHHHHH... same thing blm said... just different, LOL

    Thanks guys, I get it now!
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

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