Article:
  PHP and Heredocs
Subject:   Why not use php-style instead of perlish (2)?
Date:   2003-04-15 03:32:34
From:   anonymous2
Response to: Why not use php-style instead of perlish (2)?

HEREDOC strings are very convenient to spit out HTML, or any lengthy string blocks and it's not Perlish (!) it's derived from UNIX shell's here-document syntax!! I use both Perl and PHP for my web projects and it is pointless to say that PHP is better than Perl (both languages are fun to program with, and PHP really needs to level up with Perl regarding OOP).


Please drop by "http://theperlreview.com/" and read Ed Summer's article "Paying Homage to Perl (PHP) " in V.0-I.7

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Why not use php-style instead of perlish (2)?
    2003-04-15 09:48:25  Daniel Smith | [View]


    Yes, I completely agree. I think you meant to reply to a different message in the thread, but I know what you mean.

    My first exposure to heredocs was in the early 1980's, writing csh scripts. It's one thing missing in C/C++ that I really would have enjoyed having from time to time. Come to think of it, it would have been nice in Java, Javascript, and Tcl too.

    A few languages supporting heredocs:
    sh/bash/ksh
    csh/tcsh
    perl
    php
    python

    One of many things I like about heredocs is that using them is much less cluttered than a series of print/echo statements. It allows me to better concentrate on the content within the heredoc, such as an email message, a help blurb, or anything else that tends to be multiline.

    > Please drop by "http://theperlreview.com/" and read Ed Summer's article "Paying Homage to Perl (PHP) " in V.0-I.7

    Interestingly, that PDF file contains an article "Separating Code, Presentation, and Configuration -- brian d foy" which makes use of heredocs in Perl :-)

    Daniel Smith