heredoc usage [WAS: <OPTION]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> At 10/25/2006 04:09 PM, Stut wrote:
> >         print '<option value="'.$day.'"';
> >         if ($selected_day_of_month == $day)
> >             print ' selected';
> >         print '>'.$day.'</option>';

On Wed, 2006-10-25 at 17:35 -0700, Paul Novitski wrote:
>                  print <<< hdDay
>                  <option value="$day"$sSelected>$day</option>
>
> hdDay;

At 10/25/2006 06:57 PM, Robert Cummings wrote:
Ewww, I'll take Stut's style anyday. Heredoc has its uses, but I
wouldn't consider your above usage one of them :/ Now to add my own
flavour...
        echo '<option value="'.$day.'"'.$selected.'>'
            .$day
            .'</option>';


Rob, I'd love to know what aspect of my heredoc usage you find objectionable. From my perspective it's a single integrated expression, cleaner, easier to read and proofread, and easier to maintain than a concatenation of expression fragments strung together with syntactical punctuation and quotation marks. I especially value the fact that heredoc lets me separate program logic from text output to the greatest extent possible. Am I unwittingly committing a stylistic or logical faux pas?

Conversely, what applications of heredoc do you find valid and valuable?

I ask because I use heredoc all the time, sometimes for inline code as above but most often for template assembly, maintaining HTML in external files that can be edited independently of the PHP logic.

Curiously,
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux