justuptime.com - monitor your servers & websites

Can I mix PHP and HTML web pages?

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

He has: 57 posts

Joined: Dec 2004

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
 
?>

somewhere in the page "just to be sure"?

Thanks for any assistance, I'm new to PHP but excited to be able to use it.

Focused Investments at Secular Bull

KIJHL Hockey - Revelstoke Grizzlies

Busy's picture
Modrater

He has: 6,148 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

<?bhb if(broken){ echo("It wasn't me Smiling "); } ?>
Learn HTML the ez way - EzHTML.net

Some people are like slinkies, they dont really serve any purpose but they still bring a smile to your face when you push them down the stairs ...