简体   繁体   中英

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>

PHP文件在Server中执行,您需要本地主机服务器(如LAMP或Wamp)来执行PHP脚本

  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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM