PHP 4.0 Bug #2766: Better escaping leading to better code
| From: | ajr4 at lehigh dot edu | Date: | Fri, 19 Nov 1999 17:16:59 +0000 |
| Subject: | PHP 4.0 Bug #2766: Better escaping leading to better code | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-12777@lists.php.net to get a copy of this message | ||
From: ajr4@lehigh.edu
Operating system: All
PHP version: 4.0 Beta 3
PHP Bug Type: Feature/Change Request
Bug description: Better escaping leading to better code
A feature that would greatly improve code layout is the so called macro entity.
The reason we use HTML is because it is the easiest format that is directly related to the way we
think of document layout. i.e. "Apply this format to this region", "insert this
object here." When programmers make these documents dynamic, most of them tend to create a
patchwork of code and HTML that no longer accurately represents the document layout it produces
until after it is processed.
Inline code tags were the first step in the right direction. They allow the code to be inserted
into the document instead of vice versa. However inline code tags lead to certain common abuses i.e.
something like <NAME ATTRIBUTE="<? print $value ?>">. This kind of abuse
decreases readability by both humans and programs like a syntax highlighter in an editor and is
agains the w3c spec.
The next step that would further allow the programmer to preserve the layout structure without
obfuscating the code is the addition of what are know as macro entities. The syntax is &{expr};
and is accepted by the w3c in their HTML 4.0 spec. They are already implemented to allow JavaScript
macro entities and I believe PHP should adopt this form in addition to the inline code tags. The
code &{expr}; would be semanticly equivalent to <? print expr ?>. This method also would
have the added benefit of reducing the amount of code clutter for a very common operation - printing
a value into the document.