Re: heredoc usage [WAS: <OPTION]

From: Date: Sat, 28 Oct 2006 16:01:48 +0000
Subject: Re: heredoc usage [WAS: <OPTION]
References: 1 2 3 4 5 6 7 8  Groups: php.general 
Request: Send a blank email to php-general+get-243794@lists.php.net to get a copy of this message
On Thu, 26 Oct 2006 01:04:25 -0700, Paul Novitski wrote: It's so interesting that some details bug some people and others bug others. In an expression such as this:
         echo '<option value="' . $day . '"' . $selected . '>' . $day
. '</option>'; ...I count eight transitions (instances of switching between PHP syntax and output text) -- one each time you open or close a quote -- compared to just two transitions (the opening & closing labels) for the comparable heredoc statement:
         print <<< hdDay
         <option value="$day"$sSelected>$day</option>
hdDay;
At 10/28/2006 04:28 AM, Nisse Engström wrote:
That's funny. I count eight transitions in both examples. The difference in the second example is that the transition switches have changed from open/closing quote to '$'/not-a-variable-character.
Yes, from the point of view of the PHP parser, a transition is made each time you encounter an embedded variable requiring evaluation and each time you return to the quoted expression that doesn't require that same kind of evaluation. What I was referring to were transitions of PHP syntactical punctuation that fragment the expression from the human point of view. I personally find the heredoc expression much easier to read, proofread, and maintain because it appears to be all one simple, unbroken expression. Regards, Paul

« previous php.general (#243794) next »