#1
  1. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Apr 2000
    Posts
    1,058
    Rep Power
    22
    Hi,

    I'm new to PHP, so maybe I've simply
    overlooked the obvious, but I was wondering
    if PHP supports "Here" documents (like perl,
    or UNIX shell). Any help would be greatly
    appreciated! I hate having to all the
    quotes in my HTML. =)

    Scott
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    31
    Rep Power
    15
    I have no idea what you mean by "Here"-documents.. But I hope "having to " ment something even close to this:

    In perl (it's been some time so forgive me for minor errors :
    print "Bla?";
    print <<EOF
    <html>blablahHTML here
    <a href="http://your_link_here">Hmm.</a>
    </html>
    EOF

    In PHP:
    print "Bla?";
    ?><html>blablahHTML here
    <a href="http://your_link_here">Hmm.</a>
    </html>
    <?
  4. #3
  5. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Apr 2000
    Posts
    1,058
    Rep Power
    22
    It looks like you're saying that if I want
    to have large chunks of HTML code without
    having to the quotes, I should just put
    the HTML outside of the <? ?> tags.

    There are two reasons that I wanted to have
    all of my HTML within the PHP.

    (1) I believe that my pages will execute
    faster if they are entirely contained within
    the PHP tags (rather than switching back
    and forth)

    (2) In perl you can embed variables in the
    HTML contained in a Here document and I was
    hoping that PHP could do the same.

    Thanks for your help. =)

    Scott
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    31
    Rep Power
    15
    You can do (almost like in perl) templates like this:

    while($row=something(" ")) {
    <?
    Name: <? echo $row["name"] ?><br>
    Address: <? echo $row["address"] ?><br>
    <p>
    ?>
    }
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    8
    Rep Power
    0
    here

    <<<ENDH

    endh can be any combination of characters which are not in the here document.

    ENDH;
  10. #6
  11. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    believe it or believe it not - you code gets parsed faster if you keep your <?php to a minimum - jumping in and out of php does not make things any slower - on larger files just the opposite.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  12. #7
  13. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Apr 2000
    Posts
    1,058
    Rep Power
    22
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by firepages:
    believe it or believe it not - you code gets parsed faster if you keep your <?php to a minimum - jumping in and out of php does not make things any slower - on larger files just the opposite.
    [/quote]

    That's what I get for listening to those
    NT/ASP guys! Thanks for the tip.

    Scott
  14. #8
  15. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Apr 2000
    Posts
    1,058
    Rep Power
    22
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by geosync:
    here

    <<<ENDH

    endh can be any combination of characters which are not in the here document.

    ENDH;
    [/quote]

    Thanks! I'll give it a try.

    Scott

Similar Threads

  1. Embed images in dynamicically created word documents
    By xsurveys in forum ASP Programming
    Replies: 0
    Last Post: February 13th, 2004, 02:22 PM
  2. How to read 'My Recent documents' area?
    By gigabite in forum Visual Basic Programming
    Replies: 8
    Last Post: January 28th, 2004, 07:06 AM
  3. How to upload documents in mysql
    By sbongile in forum PHP Development
    Replies: 1
    Last Post: November 20th, 2003, 05:07 AM
  4. w3c strict errors (10), css, and js questions
    By WorldBuilder in forum CSS Help
    Replies: 12
    Last Post: November 6th, 2003, 04:48 AM
  5. downloading secure documents
    By lux in forum PHP Development
    Replies: 2
    Last Post: February 13th, 2002, 08:54 AM

IMN logo majestic logo threadwatch logo seochat tools logo