What is the difference between php and html file extensions?

后端 未结 10 1696
无人共我
无人共我 2020-12-31 18:20

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. C

10条回答
  •  盖世英雄少女心
    2020-12-31 18:40

    The difference lies in how your web server is configured, or whether you need a web server at all when trying to run the files locally (ie - with them on the computer you're currently using).

    For example, if you were to run both versions on a computer with no web server installed, the .html file will open in a browser just fine, though without doing anything with any PHP tags. The .php file, however, won't necessarily run and the browser may even try to "download" the file.

    What the file extensions are for is to tell a computer what to do with a given extension. Just like your computer will open .doc files in a word processor, or .txt files in a basic text editor. And just like you can tell your computer to open .txt files in your word processor, you can tell the web server to handle .html files the same way as .php files (which is what yours is evidently set up to do).

提交回复
热议问题