Mikaela, imagine you have a file called index.html
with the content described below:
<!DOCTYPE html>
<html>
<head>
<title>Aprendendo HTML e PHP</title>
</head>
<body>
<p>Prazer, me chamo Godfrey the King.</p>
</body>
</html>
You as a curious person, decided to change the extension to .php
.
When opening the page in your browser - remembering that you need to have a web server installed on your computer, which is easily installed using XAMPP, WAMP, Easyphp, among others. - the following sentence shall appear::
"Prazer, me chamo Godfrey the King."
If you change the code a little, to:
<!DOCTYPE html>
<html>
<head>
<title>Aprendendo HTML e PHP</title>
</head>
<body>
<?php $nome = "Mikaela"; ?>
<p>Prazer, me chamo <?php echo $nome; ?>.</p>
</body>
</html>
The phrase will be exchanged for: "Prazer, me chamo Mikaela.".
Now do a short test and change the file extension to .html
again and reload the page.
Noticed the difference?
HTML is a markup language used in the construction of
Web. HTML documents can be interpreted by browsers.
PHP is a free interpreted language, originally used only
for the development of applications present and acting on the
server. PHP scripts are interpreted on the server side.
You need to have apache installed on your server otherwise the php code will become text at the time of display.
– rray
just change the html extension to php, since your server runs php, no problem at all.
– user60252
@rray if there is no apache both php code and html also becomes text, right?
– user60252
The HTTP responses generated by your Phps can be anything, like: json, image, html, txt, etc. PHP is not the "equivalent" to HTML, it is only possible to write HTML in the middle of it that will be processed and sent to via download as if it were a pure HTML, after processing.
– Guilherme Nascimento