-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,431
  • 6
  • 46
  • 63
Louis
  • 2,854
  • 2
  • 19
  • 24

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,344
  • 1
  • 19
  • 47
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,267
  • 3
  • 15
  • 38