-5

I am trying to create a simple php page which contain only an echo, if I saved the page as ".html" it will be opened on google chrome but nothing is executed, if ".php" the page never open. any help? PS: I am new on programing

<html>
<head>
<title> test</title>
</head>
<body>

  echo "hello World";

</body>
</html>
  • 2
    Also you cannot simply open a .php in chrome on your own computer from where I'm guessing is just a plain directory. You have to put it in a webhosted directory that is setup to execute php. You CAN do this locally, but you need to setup your computer correctly (if you are using Mac OSX, its already built in... just put your files in your public web directory to test from). – IncredibleHat Feb 03 '18 at 13:37
  • 2
    From below: "that's my bad my friend... I just copied it here wrong... I am writing the php code between the two tags, the problem isn't in the code." Then how can we possibly help you? It's _your_ responsibility to ask your question clearly. Please read [ask]. – ChrisGPT was on strike Feb 03 '18 at 15:41

3 Answers3

1

You have to write your PHP code between PHP open <?php and close ?> tags.

Try this :

<html>
<head>
<title> test</title>
</head>
<body>

  <?php echo "hello World"; ?>

</body>
</html>
Syscall
  • 19,327
  • 10
  • 37
  • 52
  • that's my bad my friend... I just copied it here wrong... I am writing the php code between the two tags, the problem isn't in the code. – Rabih Elias Feb 03 '18 at 14:37
1

Php file don't run .html format and without server . Please read and understand what is php and how it is work ?. follow below link or find youtube tutorial for more visual understanding .

https://www.w3schools.com/php/default.asp
http://php.net/manual/en/

Maybe you try this :

<html>
<head>
<title> test</title>
</head>
<body>

  <?php echo "hello World"; ?>

</body>
</html>

Save file as .php format and run through a localhost server that you prefer . if you don't know what is server is follow link :
https://www.w3schools.com/php/php_install.asp
PHP server on local machine?

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Axiom_shuvo
  • 73
  • 1
  • 7
0

Download XAMPP, change your code to

<html>
<head>
<title> test</title>
</head>
<body>

  <?php echo "hello World"; ?>

</body>
</html>

Locate the folder C:/xampp/htdocs, and create the file index.php containing your code, now type "localhost" in your web browser and you're done

Hugh
  • 47
  • 2
  • 6