Re: php+html mixup in displaying multidimensional array in html tables [message #176870 is a reply to message #176858] |
Mon, 30 January 2012 13:51 |
Scott Johnson
Messages: 196 Registered: January 2012
Karma:
|
Senior Member |
|
|
On 1/29/2012 6:43 AM, Thomas 'PointedEars' Lahn wrote:
> r(dot)mariotti(at)fdcx(dot)net wrote:
>
>> After developing numerus commercial sites over the past decade+ all
>> the php I've created is by far mostly procedural. I personally never
>> leave php and output my pages with a "print<<<EOD" and the entire
>> page follows, variaables embededded and all.
>> Easy to create, read, follow, maintain, etc.
>
> Except when you want to indent or client-side validate your code. As for
> the former, the EOD (or whatever delimiter you use) must be at the
> *beginning of the line* and must at most followed by `;'. As for the
> latter, a client-side HTML validator will not see the HTML that you put out
> because to it it is PHP.
>
I use heredocs for all my forms (particularly admin) and have no issues
with client side functions on the form even ajax work flawlessly.
The browser has no idea how the info sent to it was created, only that
it is sent in proper context.
> In addition, you still would have string escaping issues and difficulties
> with function calls, and it is very inefficient to have PHP string-parse
> large chunks of code that does not need parsing in the first place.
>
I actually find using strings in heredocs is very easy. Instead of
having to escape with my typical " . $var . " now all I need is {$var}
which seems to me as more of an easier and 'template' type of design to
read.
There are times when I need to call a method inside of the heredoc in
which case I process that var in a call above the heredoc definition.
> < http://php.net/manual/en/language.types.string.php#language.types.string.sy ntax.heredoc>
>
> BTDT. Here-doc is tempting as a solution to this problem, but in the long
> run it is more trouble than it is worth.
>
I have the opposite opinion once I started to use it more often.
It is simple and easy to read part of the coding for me.
>
> PointedEars
|
|
|