【问题标题】:include 'x.php' not working on html pages [duplicate]包括'x.php'不适用于html页面[重复]
【发布时间】:2021-02-23 22:48:04
【问题描述】:

在我的网站上,顶栏、菜单和页脚作为 php 在 html 中包含指令,不适用于 *.html 文件 只有 index.html

在 chrome 检查器中,我看到 de php include 显示为命令! 什么时候重命名议程.html -> 议程.php php_menu、php_topbar 和 php_footer 再次工作

过去我必须在“.htaccess”中放置一个“addhandler”

我怎样才能让 al html 作为 php 运行


index.html

<!--Top bar start-->
<?php
    include 'php_topbar.php';
?>

php_footer.php

https://www.sportenmoedig.be/php_footer.php


php 版本: https://sportenmoedig.be/version.php

当前 PHP 版本:7.3.23


.htaccess

AddHandler 应用程序/x-httpd-php .php .htm .shtml .html


【问题讨论】:

标签: php html .htaccess


【解决方案1】:

您不能在html 页面中使用&lt;?php ?&gt; 标签,&lt;?php ?&gt; 只能在 php 文件中使用。你可以把index.html改成index.php

【讨论】:

    【解决方案2】:

    PHP脚本的开头是&lt;?php,关闭是?&gt;

    在这些标签之外,您将能够插入您的 html。这意味着您想在其中使用 PHP 的任何页面都应命名为 .php 文件。

    此资源将帮助您了解如何将 PHP 和 HTML 结合使用:

    https://www.w3schools.com/php/php_syntax.asp

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-12
      • 1970-01-01
      • 2014-03-07
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多