On Wed, 2006-10-25 at 22:53 -0700, Paul Novitski wrote: > > > 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. Now this is obviously just opinion since everyone is entitled to their own style, and while I might find it objectionable, I hardly represent the masses and their idiosyncrasies :) Now, the thing that I dislike about heredoc for such small strings is the switching between heredoc mode and the switching back. It's ugly on the scale of switching in and out of PHP tags. it would be less ugly if the closing delimiter didn't have to be at the beginning of it's own line in which case code could still maintain indentation formatting. Understandably it is not like this since it's flexibility lies in being able to place very versatile content within while not accidentally breaking out of heredoc context. To lighten the mess of heredoc I personally use the following format: <?php $foo = <<<_ <div class="$foo" id="wooohooo"> blah blah blah blah blah blah blah blah blah blah blah blah $foo blah blah blah blah blah blah blah blah blah blah blah blah blah $fee blah blah blah blah blah blah blah blah blah blah blah blah blah </div> _; ?> However that's only useful if indenting the content is not an issue. > 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? My example also illustrates the kind of content I would be willing to contain within a heredoc... namely a large chunk of content, most likely with a mix of double quotes and variables. That said, I'm still more likely not to use heredoc... I think the one exception where I'm quite likely to use heredoc is when I'm declaring a javascript function from within a PHP function. > 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. I use a tag based template system, there's no PHP in my content so my content files for the most part just look like more HTML. The templates are compiled to PHP (or raw content such as when creating stylesheets) after which they are used over and over without recompiling. here's an example of an email template: -------------------------------- Hello <jinn:render name="email" selector="firstName"/>, You or somebody posing as you has requested that your password be reset. If you did not request this email then you may disregard it and no changes will be made to your account. To continue please click on the link below and complete the form that will be presented. If clicking on the link does not open your browser then please copy and paste the address into a web browser to continue. http://<jinn:render name="email" selector="domain"/>/reset.php?rid=<jinn:render name="email" selector="serialCode"/> Sincerely, Admin -------------------------------- Here's the code that invokes the template: <?php $mail = &$this->getServiceRef( 'mail' ); $mail->addTo( $to ); $mail->setSubject( 'BlahBlah.com - Reset Password Request' ); $mail->setTemplate( '//emails/passwordResetDetails.php', $data ); $mail->send(); ?> Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php