ifacethoughts

PHP’s Alternative Syntax

PHP stands out because it is one of the first languages built for Web. No wonder it offers an alternative syntax that is more usable as a template language instead of a programming language. They help us avoid the block-kind code and have single-line PHP code. It is also simple enough for a designer to pick it up.

There are of course many template engines offered for PHP, like Smarty and PHPTAL. However, they might turn out to be heavy for many projects. In such cases, using the alternative syntax can help a lot. A couple of popular tools are WordPress and CodeIgniter.

Of course, one of the dangers of using PHP directly in templates is to make it one-stop for everything. The fact that PHP has two different syntax forms should encourage us to think about separating what to allow in templates, which can be a challenge in itself if not consciously designed.

Discussion [Participate or Link]

  1. Rob Wilkerson said:

    I’m a huge fan of using the alternate syntax in my view files. One of my favorite things about writing code in ColdFusion is how nicely it works with markup language syntax. PHP’s alternate syntax provides a similar aesthetic.

    I’m not sure I understand your last paragraph, though. I’m not sure it’s practical to exclude all PHP from view files (templates, if you prefer). In most applications I’ve ever developed there’s always a certain amount of presentation logic – loops, conditional display elements, etc. I’m not sure it’s possible to get away from that entirely, but maybe that’s just been my experience.

Say your thought!

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.

freshthoughts

contactme

Abhijit Nadgouda
iface Consulting
India
+91 9819820312
My bookmarks

badgesand...

This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.