-1

This is working when I open it with ubuntu terminal

First.php

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

But I have made one HTML with Same confiuration

<!DOCTYPE html>
<html>
<body>
<?php
echo "My first PHP script!";
?>
</body>
</html>

When I open it in browser it shows empty

Any help will be appreciated

Abhishek Parikh
  • 949
  • 1
  • 20
  • 41

3 Answers3

1

You need a php extension on any webserver running that parses the script, you cant just input php to an html file and open this one. PHP is a serverside language not a clientside

Marvin Fischer
  • 2,552
  • 3
  • 23
  • 34
0
<!DOCTYPE html>
<html>
<body>
<?php
echo "My first PHP script!";
?>
</body>
</html>

Save this file as for example mytest.php and run on the browser

output is :: My first PHP script

Try it OR you can run it from terminal as well

Mehul Kuriya
  • 608
  • 5
  • 18
-1

Always save file with php extension if it has php code for Cor PHP. You can put HTML/javascript/css code inside a filename.php file but outside tags, that will work fine.