【问题标题】:Include .shtml file in a .php page?在 .php 页面中包含 .shtml 文件?
【发布时间】:2012-11-27 21:22:36
【问题描述】:

我想在 .php 页面中包含一个 .shtml 文件。我知道这是可能的,就像我以前做过的那样(尽管我忘记了代码)。请问有人可以帮忙吗?

【问题讨论】:

  • 为什么不直接使用 php include 或 file_get_contents? shtml 现在用的不多。
  • 我的网站完全是用 shtml 编写的。我正在编写一个 php 应用程序,并且必须能够包含一个 shtml 文件
  • 您要准确归档什么?
  • 基本上我有 header.shtml 文件,我需要包含在 home.php 中
  • 您可能正在寻找virtual

标签: php html shtml


【解决方案1】:

我建议使用:

include_once('/includes/header.shtml');

【讨论】:

    【解决方案2】:

    你试过了吗:

     echo file_get_contents('/includes/header.shtml');
     // or
     echo file_get_contents('includes/header.shtml');
    

    它可能会起作用。

    但我会开始将所有模板转换为任何可用的 php 模板引擎。

    【讨论】:

    • 你的文件夹结构是什么。
    • 我们能告诉您您的文件夹布局是什么。由于'/include/header.shtml' 没有正确接缝
    • /includes/header.shtml 是正确的,因为“includes”文件夹位于域的顶层,而 shtml 文件位于其中。 test.php 文件也位于域的顶级文件夹中。
    • 根据您的最后评论,我是对的。你需要echo file_get_contents('includes/header.shtml'); 甚至只是require 'includes/header.shtml'; 都可以。试试看吧。
    • 我用过: 并且知道 test.php 正在显示一个空白页面。
    猜你喜欢
    • 2010-10-24
    • 1970-01-01
    • 2011-08-24
    • 2016-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多