localhost/test.php returns nothing

人走茶凉 提交于 2019-12-10 19:46:59

问题


I am following a tutorial "PHP & MySQL for dummies" to build a web application. I created a simple test.php file in web space (/var/www/html). The problem is that when I type localhost/test.php in the browser address window, it returns me an empty page. I tried localhost/php.info and it worked well but I could not find why test.php does not work.

This is the test.php code:

 <html>
 <head>
 <title>PHP Test</title>
 </head>
 <body>
 <p>This is an HTML line
 <p>
 <?php
    echo “This is a PHP line”;
    phpinfo();
 ?>
 </body></html>

I do appreciate any information.

Thanks.


回答1:


You said that you put your script in /var/www/html

So the link might be

localhost/html/test.php

Also check the error log file for PHP error.

# cat /var/log/apache2/error.log

EDIT: Change your quote, ” are for Word document and not programming ;-)

<html>
 <head>
 <title>PHP Test</title>
 </head>
 <body>
 <p>This is an HTML line</p>
 <?php
    echo "This is a PHP line";
    phpinfo();
 ?>
 </body>
</html>



回答2:


I have tried with this..just type the word localhost followed with name of the work eg.. localhost/test.php in the navigate bar on your browser then click enter



来源:https://stackoverflow.com/questions/23495807/localhost-test-php-returns-nothing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!