.PHP与HTML与PHP与.html

编程入门 行业动态 更新时间:2024-10-25 18:35:47
本文介绍了.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

本文发布于:2023-11-05 06:15:05,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PHP   HTML   html

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!