制作所有页面.php? [英] Make all pages .php?

查看:45
本文介绍了制作所有页面.php?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个最佳实践问题。


对于使用PHP的网站,同时拥有.htm和.php

是否合理文件?换句话说,对于没有活动内容的页面,用.php扩展名来命名它们是没有意义的。


是否有任何优势制作所有文件.php,或者将

与.htm文件混合使用是否相同?


你做什么,为什么?


感谢您的意见。

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.

推荐答案

2003年9月17日星期三10:52:52 -0400, Bruce W ... 1写道:
On Wed, 17 Sep 2003 10:52:52 -0400, Bruce W...1 wrote:
这是一个最佳实践问题。

对于使用PHP的网站,同时拥有.htm和.htm是有意义的。 php
文件?换句话说,对于没有活动内容的页面,用.php扩展命名它们是没有意义的。

制作所有文件有什么优点或缺点.php或者将它们与.htm文件混合使用?


制作所有文件的速度不利.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?
Slight speed disadvantage to making all files .php.
What do you do, and why?




使所有内容成为.phtml文件(在Apache中设置与.php相同)。


速度劣势是不明显的,这意味着如果我必须添加一些

页面的动态内容我不必更改每个链接。


但是,我最近的网站实际上是对象生成所以每页有

对象形成布局。


干杯,

Andy



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


Bruce W ... 1写道:
Bruce W...1 wrote:
这是一个最佳实践问题。

对于使用PHP的网站,是吗?有意义同时拥有.htm和.php
文件?换句话说,对于没有活动内容的页面,用.php扩展命名它们是没有意义的。

制作所有文件有什么优点或缺点.php ,或者将它们与.htm文件混合使用?

你做什么,为什么?


我的所有页面都是PHP


以下是我的理由:

- 我正在使用会话。如果用户仅使用.htm网址播放一小段

期间,会话将过期,并且它不应该过期,因为用户

仍在使用该网站。

- 如果用户不支持cookie,会话ID将由PHP在URL(URL重写)中传输。
。因此,纯HTML页面将会失去会话。

- 我使用PHP对所有页面进行连贯的查看。标题,左边

菜单,所有页面的右侧菜单和页脚是相同的,并且每个都是在他们自己的单个PHP文件中定义的,它们都包含在PHP中。使用

HTML将迫使我在每个HTML页面中硬编码所有这些部分,

这将导致维护噩梦。


JB。

感谢您的参与。
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.










这是一个最佳实践问题。

对于使用PHP的网站,同时拥有.htm
和.php文件是否有意义?换句话说,对于没有活动内容的页面,用.php扩展名命名是没有意义的。

制作所有文件有什么优点或缺点.php ,或者将它们与.htm文件混合使用相同吗?
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?




我坚信,对于最佳实践,不应该使用.php

但请改用.html。当然使用混合物是在寻找麻烦。

这同样适用于令人讨厌的扩展,如.php3,.php4,.phtml和

之类的。


使用.php宣传你的服务器技术,人们不太熟悉

如果你不得不打印地址,导致你必须改变所有

如果您决定更改其他技术,则可以使用

产生.html和.php的混合。此外,如果您决定将

位的PHP添加到现有的.html文件中,那么您就不必更改

URL(以及重定向的问题) )。


鉴于现在许多网站将使用PHP进行某种类型的房屋

样式使用(以及其他任何东西..)PHP将根据定义,需要解析大部分文件(如果不是所有文件)。因此,设置.html来解析PHP。


我从来没有遇到过任何明显的性能损失,即使在那些几乎没有使用的网站上也是如此PHP解析器。我敢说可能会有一个非常繁忙的网站,但我怀疑大多数人都不会碰到那个

而且上面的维护优势超过了它们的缺点。


只需添加


AddType application / x-httpd-php .html


到你的.htaccess文件或Apache配置。什么可以更简单?

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



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


这篇关于制作所有页面.php?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆