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:
- Why the file is behaving in the same manner with both the
extensions? - What is the difference between the
.phpand.htmlfile 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.