NYCPHP Meetup

NYPHP.org

[nycphp-talk] Parse HTML Files as PHP

Greg Rundlett (freephile) greg at freephile.com
Sun Feb 22 15:10:56 EST 2009


On Sun, Feb 22, 2009 at 8:44 AM, tedd <tedd at sperling.com> wrote:
> At 11:15 PM -0500 2/21/09, Ajai Khattri wrote:
>>
>> On Fri, 20 Feb 2009, Peter Sawczynec wrote:
>>
>>>  Anyone have any comment on this strategy pro or con?
>>
>> Not good for performance or scalability. A PHP framework with routing
>> should allow you use URLs with .html at the end without resorting to
>> changing Apache's behavior.
>> --
>> Aj.
>
> Now that I think about it, Apache's behavior at default is to consider
> embedded php -- so I'm not sure why one would want to add a directive to
> parse html files as php.

Apache's default for .html is text/html

> Furthermore, if you don't wrap your html code in a heredoc wrapper, the html
> code will cause the script to crash.

That's not correct.  If .html files are parsed through Mod_php, the
default behavior of the PHP module is to output the contents just like
text/html, which is why you have to add PHP processing instructions
(aka "tags") to your PHP files to turn ON php i.e. <?php print
("foo"); ?>    I'm saying that turning on PHP processing of regular
HTML files will output HTML just like if you didn't pass the file
through mod_php.

-- 
Greg Rundlett
Web Developer - Initiative in Innovative Computing
http://iic.harvard.edu
camb 617-384-5872
nbpt 978-225-8302
m. 978-764-4424
-skype/aim/irc/twitter freephile
http://profiles.aim.com/freephile



More information about the talk mailing list