Flyn Sequeira
Flyn Sequeira

Reputation: 692

My PHP file doesn't execute in the browser

Nothing appears in the browser when I open this file. I assumed it's supposed to show "it works," but instead it shows nothing when the file is opened in the browser.

<!DOCTYPE html>

<html>
<body>

<?php

echo "It works";
?>

</body>
</html>

Upvotes: 0

Views: 4521

Answers (3)

Choxx
Choxx

Reputation: 945

PHP is a server side language. If you want any php page to execute then definitely you need server whether it is virtually created or it is real. You are trying to run the php page directly which has no meaning to browser. You may use software like Wamp, Xamp that creates a virtual server on your PC. Try using this, then come back if you face any problem. For more info on how to use these, just GOOGLE them. You'll find millions of solutions there. Good Luck!

Upvotes: 0

at15
at15

Reputation: 139

  1. php files are executed in Server. After you installed Wamp, put your php code in www folder name as test.php, and go to localhost/test.php in your browser, you will see it works
  2. when you open a file directly in your browser, it is treated as html file. the url would be like file:///D:/web/hello.html. But <?php ... ?> is not valid html so you got a blank page.

some links that might be useful to you

Upvotes: 1

Jithin Sha Ma
Jithin Sha Ma

Reputation: 11

PHP files are executed in Server , You need a local host server like LAMP or Wamp needed to execute a PHP script

Upvotes: 1

Related Questions