Can I mix PHP and HTML web pages?
I'm currently building a new site which will incorporate a bunch of PHP scripts.
Obviously the webpages which contain these scripts must end with .php ... but I was wondering something. Can I use both the .html and .php extensions (depending on the page) for the same site? In other words, I will use the .php extension for those pages that require it, but for all of the other pages can I just continue to use the .html extension? Is this acceptable?
Another related question I have is... if I used the .php extension with ALL of my webpages in the site will it cause any problems with the pages that don't have any PHP code in them? If I did this, would I then have to include the following code
<?php
?>
Thanks for any assistance, I'm new to PHP but excited to be able to use it.
Busy posted this at 21:44 — 25th March 2006.
He has: 6,151 posts
Joined: May 2001
Just add
AddType application/x-httpd-php .php .html .phtml
to your .htaccess file and you can just use .html or .phtml file extensions for all pages
if you just opt for .php extension there is no worry about jumping in and out of php via the tags you noted, infact it's faster to use just html when there are no php queries in a block
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.