Escaping from HTML is a very cool feature of PHP because it allows easily to inject portions of dynamic content into predefined HTML template. But when you come to HTML tags with many dynamic attributes and relatively complex logic beyond them, this cool feature turns into complete disaster. If you constantly develop view templates or web page scripts then you definitely know how many times you hated starting yet another “<?php echo…” just for another attribute value.
Right, even if you strongly pretend to write clean code, multiple dynamic attributes per HTML tag, variable styles or class sets usually result in total mess of HTML and PHP which is very hard to read. This usually happens with form elements or jQuery widgets that require a lot of data converted into HTML attributes, classes and styles.
Read the rest of this entry »