What is the difference between php and html file extensions?

后端 未结 10 1635
无人共我
无人共我 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:25

    A php indicates that it is dynamically generated using PHP language. However, you don't see the page as it was originally written, but rather the end result. The end result is, in fact, an html file.

    So to answer your question, to the client, a page ending in php or html will support exactly the same contents (which is to say, an html document). Even though browsers shouldn't, they often attempt to visualize tags which make no sense to them (browser interpreting <?php echo "Hello!" ?> for instance might decide "Hello" is the text to display).

    Though an html really should never have php tags in it because it isn't meant to be in an html document (php documents are traslated into html documents, thus removing php tags).

    0 讨论(0)
  • 2020-12-31 18:25

    PhP is server side.

    HTML is client side.

    Plus, on the web, filetypes mean nothing. They are overridden by the !DOCTYPE declaration.

    0 讨论(0)
  • 2020-12-31 18:26

    an extension is how your operating system recognizes your file and decides what to do do with it i.e. which application should it be opened with.

    php is a server side scripting language. It is interpreted by a web server that has php installed on it . For eg in a XAMPP the php.exe file in XAMPP/php folder interprets the php file/commands.

    HTML is the standard for sending information over the internet . So the final result of your file is a html page despite whichever serverside scripting language you use. The web server you are using will process the php commands and convert them to corresponding html and send them to your browser. The browser then processes (compiles) the html code to display you your web page.

    HTML is essentially all that you see on your browser. PHP is used to interact with the web server and process information that is entered by the user into a web browser via forms or execute underlying third party scripts (such as TCL scripts) under a link to perform a automation functionality in the background hidden from the user who is using on the web site or parse a XML file or extract information from a database or maintain session information and much more.

    In general PHP handles the interaction of a web application with a server that is configured to run PHP. HTML simply dumps the results in browser.

    You can think of it this way- HTML is simply how your web site looks ... PHP is what makes your site intelligent so that it can interact with a user...

    your getting the same result because php can be embedded in html and your web server processes both the files to give you identical results. However if you didn't have php installed on your web server you would get as output in your browser.

    0 讨论(0)
  • 2020-12-31 18:34

    You can configure your web server to handle .php and .html files differently. Your webserver is configured to interpret both as PHP. Most servers handle .php as PHP, and serve .html as-is. That is, if you put your code in an HTML file, the PHP code will not run and will show up in the output.

    Some people find it nicer to have .html in the URL instead of .php. It may be useful if your users download your page and try opening them by double-clicking on them.

    0 讨论(0)
  • 2020-12-31 18:38

    PHP: Pre Hyper Processot : a server side script language HTML: Hyper text markup language

    ".php" and ".html" are just the file extensions however if you want to use php code you must run it off a server which supports php.

    0 讨论(0)
  • 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).

    0 讨论(0)
提交回复
热议问题