PHP不在HTML中呈现

2022-01-25 00:00:00 iis-7 php

我正在使用带有 IIS 7 的 Windows 7.我正在尝试开始使用 PHP.我执行了以下操作:

I am using Windows 7 with IIS 7. I am trying to get started with PHP. I have performed the following:

  1. 使用 Web 平台安装程序安装 PHP
  2. 通过在我的网站根文件夹内的 PHP 管理器上使用检查 phpinfo()"验证 PHP 已安装(全部在我的本地计算机上)

当我测试 PHP 是否正在处理一个简单的 HTML 页面时,如下所示:

When I test to see if PHP is working with a simple HTML page as follows:

<!DOCTYPE html>
<html>
<body>

<?php
echo "My first PHP script!";
?>  

</body>
</html>

Chrome 不渲染任何东西.我期待看到文字.

Chrome does not render anything. I am expecting to see the text.

谁能告诉我如何进行?

谢谢

推荐答案

如果出现此问题请检查:

If this problem ocurrs check:

  • 文件是否有扩展名.php?
  • 服务器上的路径是否正确?

重要的是要记住,我假设您有一个激活了 php 支持的服务器.在服务器上,PHP文件的默认扩展名是.php,但您可以向管理员查询以保证.

Its is important to remember that I am assuming that you have a server with php suport activated. On the server, the default extension to PHP files is .php, but you can check with the administrator to garantee.

您还可以检查错误日志是否已启用.当它被禁用并且代码有语法错误时,屏幕上不会显示任何内容.您可以在此处阅读更多信息:https://stackoverflow.com/a/5438125/1735789

You can also check if the error log is enable. When it is disabled, and the code has a syntax error, nothing is showed on the screen. You can read more here: https://stackoverflow.com/a/5438125/1735789

相关文章