-2

I cannot display using php, what am I doing wrong ?

I have this file :

<!DOCTYPE html>
<html>
  <body>

  <?php
    echo "My first PHP script!";
  ?> 

  </body>
</html>

in a file called test.html.

When I open that file in my browser, there is nothing shown.

Where is my problem ?

Albzi
  • 15,201
  • 5
  • 43
  • 61
Louis
  • 2,826
  • 1
  • 18
  • 23

3 Answers3

1

Your file should be saved as a php-file.

Like:

index.php

Also you'll need a server to host the files on. You can do this locally with USB-Webserver, xampp etc.

Starfish
  • 3,109
  • 1
  • 14
  • 39
0

file Type change

 test.html

to

 test.php
Punitha Subramani
  • 1,467
  • 1
  • 8
  • 6
0

Bro HTML don't run PHP code you have to save the file as .php and paste this code on it.

<!DOCTYPE html>
<html>
<body>

<?php
echo "My first PHP script!";
?> 

</body>
</html>

Hope this helps you

Utkarsh Dixit
  • 4,153
  • 3
  • 14
  • 36