简体   繁体   English

PHP包含不适用于HTML

[英]PHP include doesn't work in HTML

The following html does not produce any response from the included php file. 以下html不会从包含的php文件中产生任何响应。

<!DOCTYPE html>
<html>
<body>
Here is some text. <br>
<?php include 'hello.php'; ?>
</body>
</html>

The hello.php file contains the ubiquitous <?php echo "Hello world!"; ?> hello.php文件包含无处不在的<?php echo "Hello world!"; ?> <?php echo "Hello world!"; ?>

Additional info: 附加信息:

  • The line of text displays properly. 文本行显示正确。
  • PHP is installed and running properly. PHP已安装并正常运行。 A call to from within the source directory produces the expected config data. 在源目录中对的调用会产生预期的配置数据。
  • The html document is named test.php 该html文档名为test.php
  • error_reporting(E_ALL); 使用error_reporting(E_ALL); produces no additional data. 不产生任何其他数据。

  • at the end or first of your html page add this o see what is disrupting: 在您的html页面的末尾或第一行添加以下内容,以查看正在破坏的内容:

    <?php error_reporting(-1); ?>
    

    and this for your include: 这包括:

    <?php include("file.php"); ?>
    

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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