Forum Moderators: coopster
In order to streamline my workflow, I use a lot of includes to generate headers, footers, and main content.
I have a friend who uses .tpl as the extention to his included files, but he's not able to really explain to me the benefits or drawbacks to a .tpl vs a .php extension.
Can anyone give some insight on this topic? Why one would use one extension vs the other?
Neophyte
tpl sounds like he uses dreamweaver, or used to.
people use many different things, common usage I've seen or heard of
.lib - straight function libraries, no html
.inc - files to be included that contain html
.php - everything else
some people use combination extensions as well
.lib.php
.inc.php
.php
the key to these is you always want all of your php files to be parsed for php otherwise if they are called through a browser they show the source code and that is a bad thing.
Hummm, some of these .tpl pages do contain php code which indeed are rendered to the browser as plain text if just the .tpl page is loaded.
I am getting use to the .tpl extension and like it because it's easy for me to see that this is an included file (my own issues of ease of organization), but I do want any important code hidden.
when you're talking about altering the server settings can I alter the htaccess file to render .tpl files as .php on the server?
Or, would everyone agree - since there is php code inside most of these files - that it's just better/easier to stick with a .php extension.
Neophyte
Assuming you are using Apache (it may be similar on other HTTPD servers, but I don't know), and you have access to the httpd.conf file, you could find the line:
AddType application/x-httpd-php .php And add whatever file extensions you wish to be passed to the PHP engine after the '.php', seperated by a space (it may contain extensions other than just .php).
Otherwise, you can add a handler to a .htaccess file:
AddHandler application/x-httpd-php .blah Just in case you aren't aware, a .htaccess file has influence over all directories located under the directory it is placed in.
After much mental angst, I've decided to drop the .tpl extension and just go for .inc.php as suggested by Jaktar - this way I know it's an include template (of sorts) and any php code with won't be displayed.
Thanks for everyones advice.
Neophyte