简体   繁体   English

[HTML / PHP]:是否需要更改.html文件的扩展名

[英][HTML/PHP]: Do I need to change the extension of .html file

If I create a simple .html file with a table inside it. 如果我创建一个带有表的简单.html文件。 Within one of the columns of a table, if I insert PHP opening and closing tags, and even just type echo, it is not working. 在表的一列中,如果我插入PHP的开始和结束标签,甚至只是键入echo,它都将无法工作。 Do I need to change the extension of the file to .php? 我需要将文件的扩展名更改为.php吗?

Changing the file to .php would be the quickest solution. 将文件更改为.php将是最快的解决方案。

An alternate solution would be to use Apache's addType to allow apache to serve PHP pages with a different extension. 另一种解决方案是使用Apache的addType允许apache提供具有不同扩展名的PHP页面。

AddType application/x-httpd-php .html .htm

是的,在大多数情况下。

The webserver needs to know it has to process the file through the php processor, instead of just giving it to the user as is the default for a .html file. 网络服务器需要知道它必须通过php处理器来处理文件,而不是像.html文件的默认设置那样仅将其提供给用户。 So renaming to .php is the easiest way to get that. 因此,重命名为.php是最简单的方法。

If you use AddType, then all html files are going through the php processor, which might slow things down too much. 如果使用AddType,则所有 html文件都将通过php处理器,这可能会使速度降低太多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM