php和html文件扩展名有什么区别? [英] What is the difference between php and html file extensions?

查看:144
本文介绍了php和html文件扩展名有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .php 文件,其代码如下。当我将文件的扩展名更改为 .html 时,它的行为方式也是相同的。任何人都可以解释以下内容:


  1. 为什么文件的行为与
    的两个扩展名相同?

  2. .php .html 文件扩展名之间的区别是什么?

.php 档案

 < HTML> 

< head>
<! - 一些html代码 - >
< / head>

< body>
<?php echo你好! ?>
< / body>

< / html>


解决方案

filetype只是识别文件的一种方式,你不能总是信任它们。

根据你的web服务器配置,你会看到不同的结果。



.html通常只用于没有服务器端代码的HTML。



.php用于服务器端php代码和html。



它们可以用于任何事情,它只取决于设置。


I am having a .php file with the following code. While I am changing the extension of the file as .html then also it is behaving in the same way. Can anyone explain the following:

  1. Why the file is behaving in the same manner with both the extensions?
  2. What is the difference between the .php and .html file extensions?

.php file

<html>

     <head>
          <!-- some html code -->
     </head>

     <body>
          <?php echo "Hello!" ?>
     </body>

</html>

解决方案

The filetype is just a way to identify the file, you can't always trust them.

Depending on your web server configuration, you will see different results.

.html is generally use just for html with no serverside code.

.php is used for serverside php code and html if required.

They can be used for anything, it just depends on the setup.

这篇关于php和html文件扩展名有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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