views:

63

answers:

2

Why are scripts given .phtml extension while working with zend framework?

+7  A: 

The .phtml extension applies only to view files as far as I can tell.

Matthew Weier O'Phinney gives these reasons why he proposed that .phtml be used for views:

I actually chose .phtml as (a) most apache configurations specify it as an alternate extension associated with the PHP engine, (b) most IDEs and text editors will identify .phtml as PHP + HTML for syntax highlighting, and (c) it visually separates template scripts from other PHP files in the directory tree.

So it's not much of a deal; it just makes it clearer that view files are the ones that largely comprise PHP interspersed in HTML templates for your applications. And as he said in point (b), most IDEs and editors recognize .phtml files so you shouldn't run into trouble dealing with them.

BoltClock
you can actually make your view scripts whatever extension you prefer if you register the extension to apache and your editor knows how to read it.
Elzo Valugi
A: 

To quote Mathew Weier O'Phinney, the person who propsed the use of .phtml:

Suffixes are a developer preference, really; you don't need to use .tpl with Smarty, nor .php with Zend_View. I actually chose .phtml as (a) most apache configurations specify it as an alternate extension associated with the PHP engine, (b) most IDEs and text editors will identify .phtml as PHP + HTML for syntax highlighting, and (c) it visually separates template scripts from other PHP files in the directory tree.

ivans