473,581 Members | 3,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make all pages .php?

This is a best practices question.

For a website where PHP is used, does it make sense to have both .htm and .php
files? In other words, for pages that have no active content there's no point
in naming them with a .php extension.

Is there any advantage or disadvantage to making all files .php, or the same for
mixing them with .htm files?

What do you do, and why?

Thanks for your input.
Jul 17 '05 #1
31 3828
On Wed, 17 Sep 2003 10:52:52 -0400, Bruce W...1 wrote:
This is a best practices question.

For a website where PHP is used, does it make sense to have both .htm and .php
files? In other words, for pages that have no active content there's no point
in naming them with a .php extension.

Is there any advantage or disadvantage to making all files .php, or the same for
mixing them with .htm files?
Slight speed disadvantage to making all files .php.
What do you do, and why?


Make everything a .phtml file (set up in Apache to be the same as .php).

The speed disadvantage is unnoticable and it means if I have to add some
dynamic content to a page I don't have to change every link to it.

However, my recent sites are virtually object generated so every page has
objects in it that form the layout.

Cheers,
Andy
Jul 17 '05 #2
Bruce W...1 wrote:
This is a best practices question.

For a website where PHP is used, does it make sense to have both .htm and .php
files? In other words, for pages that have no active content there's no point
in naming them with a .php extension.

Is there any advantage or disadvantage to making all files .php, or the same for
mixing them with .htm files?

What do you do, and why?

All my pages are PHP

Here are my reasons:
- I'm using sessions. If the user only plays with .htm URLs for a small
period, the session will expire, and it shouldn't expire since the user
is still using the site.
- If the user doesn't support cookies, the session ID will be
transmitted by PHP in URLs (URL rewriting). Plain HTML pages will thus
lose the session.
- I use PHP to have a coherent look for all the pages. The header, left
menu, right menu and footer of all the pages are the same, and are each
defined in their own single PHP file, which are included by PHP. Using
HTML would force me to hardcode all these parts in every HTML page,
which would lead to a maintenance nightmare.

JB.
Thanks for your input.


Jul 17 '05 #3


This is a best practices question.

For a website where PHP is used, does it make sense to have both .htm
and .php files? In other words, for pages that have no active content
there's no point in naming them with a .php extension.

Is there any advantage or disadvantage to making all files .php, or the
same for mixing them with .htm files?


I am a strong believer that, for best practice, one should never use .php
but use .html instead. Certainly using a mixture is asking for trouble.
The same applies to nasty extensions like .php3, .php4, .phtml and the
like.

Using .php advertises your server technology, is less familiar to people
if you are having to print an address, results in you having to change all
your URLs if you then decide to change to some other technology, and can
result in a mixture of .html and .php. Also, if you then decide to add
bits of PHP to an existing .html file you don't then have to change the
URL (and mess about with redirections).

Given that many sites these days will be using PHP for some sort of house
style use (as well as anything else..) PHP will, by definition, need to be
parsing most if not all files. Therefore, set .html to be parsed for PHP.

I've never encountered any noticable performance hit, even on sites that
barely make use of the PHP parser. I dare say there might be on an
extremely busy site, but I suspect most people would never run into that
and the above maintenance advantages outweigh the disadvantages.

Just add

AddType application/x-httpd-php .html

to your .htaccess file or Apache config. What could be simpler?
Martin Lucas-Smith www.geog.cam.ac.uk/~mvl22
www.lucas-smith.co.uk

Jul 17 '05 #4
Martin Lucas-Smith wrote:

I am a strong believer that, for best practice, one should never use .php
but use .html instead. Certainly using a mixture is asking for trouble.
The same applies to nasty extensions like .php3, .php4, .phtml and the
like.

Using .php advertises your server technology, is less familiar to people
if you are having to print an address, results in you having to change all
your URLs if you then decide to change to some other technology, and can
result in a mixture of .html and .php. Also, if you then decide to add
bits of PHP to an existing .html file you don't then have to change the
URL (and mess about with redirections).

Given that many sites these days will be using PHP for some sort of house
style use (as well as anything else..) PHP will, by definition, need to be
parsing most if not all files. Therefore, set .html to be parsed for PHP.

I've never encountered any noticable performance hit, even on sites that
barely make use of the PHP parser. I dare say there might be on an
extremely busy site, but I suspect most people would never run into that
and the above maintenance advantages outweigh the disadvantages.
=============== =============== =============== =============== =

That makes sense, but how do you set .html to be parsed for PHP? I'm using IIS
on Windows 2000. I suspect this is done in IIS?

If that's the case I'm screwed because I use a hosting company (also running Win
2000) and they would not let me access the IIS settings. But perhaps they
already have it setup this way, I'll ask.

Thanks. Just add

AddType application/x-httpd-php .html

to your .htaccess file or Apache config. What could be simpler?

Martin Lucas-Smith www.geog.cam.ac.uk/~mvl22
www.lucas-smith.co.uk

Jul 17 '05 #5
Jean-Baptiste Nizet wrote:

All my pages are PHP

Here are my reasons:
- I'm using sessions. If the user only plays with .htm URLs for a small
period, the session will expire, and it shouldn't expire since the user
is still using the site.
- If the user doesn't support cookies, the session ID will be
transmitted by PHP in URLs (URL rewriting). Plain HTML pages will thus
lose the session.
- I use PHP to have a coherent look for all the pages. The header, left
menu, right menu and footer of all the pages are the same, and are each
defined in their own single PHP file, which are included by PHP. Using
HTML would force me to hardcode all these parts in every HTML page,
which would lead to a maintenance nightmare.

JB.

=============== =============== =============== ==============

Very good point. The session state is an overwhelming reason.

I'm new to PHP. Can you point me to information on how to put the common page
elements in separate files, assuming you are not using frames? Can this be done
without using frames?

I know that a similar ability is done with ASP.NET User Controls.

Thanks.
Jul 17 '05 #6
bruce, i'm pretty new to php, however, i use php includes to keep my
repetitive html code in one location (ex, header, menu bars, footer).
since all my pages use includes, they have are .php.

if you aren't using includes for repetitive html code, i recommend you
do so.

if you hve straight html, my bet is to not to use .php if you have no
php code b/c it doesn't make sense to send those pages to the php
processor - that's inefficient.

"Bruce W...1" <br***@noDirect Email.com> wrote in message news:<3F******* ********@noDire ctEmail.com>...
This is a best practices question.

For a website where PHP is used, does it make sense to have both .htm and .php
files? In other words, for pages that have no active content there's no point
in naming them with a .php extension.

Is there any advantage or disadvantage to making all files .php, or the same for
mixing them with .htm files?

What do you do, and why?

Thanks for your input.

Jul 17 '05 #7
bruce, it works like this...

<?PHP

INCLUDE ('includes/logoHeader.inc. php');

INCLUDE ('includes/hNavBar.inc.php ');

INCLUDE ('includes/vNavBar.inc.php ');

?>

i have three files in a my include folder. One for the header, one
for the horizontal navigation bar and one for the vertical one.

just put your plain old vanilla html code into the logoHeader.inc. php
file. php will bring it in as is.

i put these "includes" on every page.

"Bruce W...1" <br***@noDirect Email.com> wrote in message news:<3F******* ********@noDire ctEmail.com>...
Jean-Baptiste Nizet wrote:

All my pages are PHP

Here are my reasons:
- I'm using sessions. If the user only plays with .htm URLs for a small
period, the session will expire, and it shouldn't expire since the user
is still using the site.
- If the user doesn't support cookies, the session ID will be
transmitted by PHP in URLs (URL rewriting). Plain HTML pages will thus
lose the session.
- I use PHP to have a coherent look for all the pages. The header, left
menu, right menu and footer of all the pages are the same, and are each
defined in their own single PHP file, which are included by PHP. Using
HTML would force me to hardcode all these parts in every HTML page,
which would lead to a maintenance nightmare.

JB.

=============== =============== =============== ==============

Very good point. The session state is an overwhelming reason.

I'm new to PHP. Can you point me to information on how to put the common page
elements in separate files, assuming you are not using frames? Can this be done
without using frames?

I know that a similar ability is done with ASP.NET User Controls.

Thanks.

Jul 17 '05 #8
No my hosting company does not have IIS set for PHP to parse HTML files, though
I can request this.

If you really want to hide your technology there's an easier way. At your
domain registrar have the name server forward with masking. This hides all file
names.
Jul 17 '05 #9
Thanks. I'm now learning about this, it's a very good idea. Never realized
that includes can be used with straight html files as well. I thought it was
just an ASP thing. In ASP.NET they are now called User Controls.
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
2960
by: madsgormlarsen | last post by:
Hi I need to make at mulitlingual website, with php amd mysql, and I am looking for tutorils or books that explains about how to best do this. Hop ypu have some suggestions as to were I can find information about this. Mads
3
1720
by: Danny | last post by:
How do you guys make listings such as product listings and their detail pages more crawler friendly, if they are genrated using dynamic asp pages. If your ASP uses a format like this: www.mysite.com/products.asp?idnum=3444 to display detail pages, how can I apply SEO to this format?? I know unix hosts use the mod rewrite, but I do not have...
67
5983
by: Sandy.Pittendrigh | last post by:
Here's a question I don't know the answer to: I have a friend who makes very expensive, hand-made bamboo flyrods. He's widely recognized (in the fishing industry) as one of the 3-5 'best' rod makers in the world. He gets (sic) close to $5000 per custom made flyrod. A surprising number of people buy these fishing rods and never use...
2
3796
by: Bhupesh Naik | last post by:
This is a query regarding my problem to make a spell and grammar check possible in text area of a web page. We have aspx pages which are used to construct letters. The browser based screens provide text area where the user can insert big chunks of text and submit it all to the server paragraph by paragraph. The requirement is to do a...
10
3220
by: moondaddy | last post by:
I'm writing an ecommerce app in asp.net/vb.net and need to make the pages searchable and crawlable by spiders, particularly Google's. As far as I know, if my pages's contents are mostly populated by user controls on a single page and I call these different controls by passing one or more parameters like this: ...
6
2247
by: briand | last post by:
How do I make many pages with the same layout? I have created header, side bar, main body, and footer web controls and added them to a table. I have many pages that want to use this same layout, BUT I DON"T to have to duplicate the layout in each page. Is it possible to use the layout from one base class or template? Inheritence only inherits...
17
3144
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content pages? Kinda sorta a critical point no? Am I missing something? Rob. P.S. the day I find a book that actually is useful rather than just a
4
1696
by: bienwell | last post by:
Hi all, I have .NET framework 1.1 and 2.0 installed in the same server. I had some web pages developed in Visual Studio.NET 2003 and some inline code web pages before (framework 1.1) . Now I start some web pages from Visual Studio.NET 2005 (framework 2.0). Can I set some virtual directories work for 1.1 and some for 2.0 ? If so, please...
3
1534
by: Jason | last post by:
Will just getting VB.net allow me to make asp server pages, or web applications? Or do I need the whole suite?
0
7860
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8299
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8166
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6546
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3799
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1398
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1127
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.