On Sun, Jan 2, 2011 at 12:16 PM, Ashley Sheridan
<a...@ashleysheridan.co.uk>wrote:

> On Sun, 2011-01-02 at 11:48 -0500, ad...@buskirkgraphics.com wrote:
>
> > Add this to your .htaccess file and HTML files will be handled like PHP
> > files allowing you put PHP in HTML files.
> >
> > AddType application/x-httpd-php .html
> >
> >
>
I wouldn't recommend having .html parsed as PHP though, as it will slow
> down your website/application unnecessarily for any .html files that
> contain no PHP code, as PHP still has to parse the file for any code,
> even if there is none. Leave .html files for static pages that you
> produce with a PHP app for example, or use MOD_REWRITE to reference PHP
> scripts when certain .html files are requested by the browser, as this
> can be a whole lot more specific and selective and won't introduce
> problems later on.
>


I tend to disagree with Ashley on this topic.  For many websites, I'll start
out making all pages .php, even if they don't require PHP at the moment.
 That's for a couple reasons.

1) A few years back, there was certainly a significant performance advantage
to keeping essentially static pages html.  However, in my current
benchmarking (using both siege and ab on my Ubuntu servers using apache with
mod_php), if I use a cache such as APC and a well-configured apache server,
PHP tends to perform just as well (or sometimes even better) than the html
version.

Rasmus has demonstrated similar performance results:
http://talks.php.net/show/froscon08/24

2) I don't want to have to change urls site-wide and set up redirects from
the old url whenever a page requires adding dynamic capabilities.  By making
all pages PHP right from the beginning, adding dynamic capabilities is a
snap as I just add the functionality.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

Reply via email to