【发布时间】:2012-08-27 11:36:15
【问题描述】:
【问题讨论】:
【问题讨论】:
Python Webserver 将您的 PHP 文件发送到浏览器的原因可能是因为它没有配置或无法处理 PHP 文件。见https://serverfault.com/questions/338394/how-to-run-php-with-simplehttpserver
PHP 5.4 有一个built-in webserver。你可以像这样从命令行调用它:
php [options] -S <addr>:<port> [-t docroot]
示例
C:\Users\Gordon>php -S 127.0.0.1:80 -t .
PHP 5.4.0 Development Server started at Sun Sep 02 14:20:28 2012
Listening on 127.0.0.1:80
Document root is C:\Users\Gordon
Press Ctrl-C to quit.
请注意,如果您省略-t,PHP 将使用当前工作目录。
【讨论】:
cd 到文件夹并运行 php -S 127.0.0.1:8000。在浏览器中打开http://localhost:8000/ 或http://127.0.0.1:8000/ 时,该文件夹中的网页index.html(使用w3school 代码)为空白。但是,浏览器中确实会出现console.log 消息。
.。但是,即使这样,您的文件在调用 index.html 时也不会被解析。它必须是 index.php。