.PHP与HTML与PHP与.html [英] .php with HTML versus .html with PHP

查看:75
本文介绍了.PHP与HTML与PHP与.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开始构建一个需要HTML和PHP的网站时,我是否应该使用PHP制作一个带有PHP的.html文件(如文件应该是index.html,但在其中有会是各种标签)?或者,我是否应该制作文件.php文件,并在其中简单地包含HTML(就像文件中的那样,再次说,index.php,它将以PHP开始,我将简单地交织在一起HTML)?



TL; DR:我应该将HTML编译为.php文件还是将PHP编入.html文件? 解决方案

它应该是一个带有编织HTML的PHP​​文件。默认情况下,如果您的服务器看到一个HTML文件,它认为它不需要处理页面上的脚本并将其呈现。如果它看到一个PHP扩展,它就知道它需要通过PHP处理器运行。

您可以修改您的htaccess,以允许HTML通过处理器呈现,但实际上并不需要您对其进行修改,特别是如果您是初学者。

When I am starting to build a site that is going to require both HTML and PHP, should I be making a .html file with PHP in it (as in the file would be, say, index.html but within it there would be various tags)? Or, should I be making the files .php files and simply include HTML within it (as in the file would be, again say, index.php and it would start as PHP and I would simply intertwine HTML)?

TL;DR: Should I be weaving HTML into .php files or weaving PHP into .html files?

解决方案

It should be a PHP file with HTML "weaved" into it. By default if your server sees an HTML file it does not think it needs to process scripts on the page and will render it. If it sees a PHP extension, it knows it needs to run through the PHP Processor.

You can modify your htaccess to allow HTML to be rendered through the processor, but there really is no need for you to be modding that, especially if you are a beginner.

这篇关于.PHP与HTML与PHP与.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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