0

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>
5
  • your Apache is stoped!start all services Commented Mar 29, 2015 at 6:02
  • if Apache was stopped, the output would be cannot connect to the server. Commented Mar 29, 2015 at 6:05
  • Are you sure you have php enabled on your server? create a new file called test.php and place the content inside below: <?php phpinfo(); ?> Commented Mar 29, 2015 at 6:11
  • PHP "executes" on the server, not in the browser. Is your http server configured to handle PHP? Commented Mar 29, 2015 at 6:34
  • im hoping you named the page with a .php extension and called the page directly. Commented Mar 29, 2015 at 6:37

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

1
  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

Comments

0

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.