【问题标题】:I can't include my header我不能包含我的标题
【发布时间】:2017-02-17 09:04:19
【问题描述】:

<?php

require('../includes/config.inc.php');
include ('../includes/header.html');
$page_name = NAME;

$page_title = 'Home';
?>

<div  style="background-color:green;" class="container">
    <div class="section">
        <div class="row">
            <div class="col s6">
                <h3>Welkom</h3>
            </div>
            <div class="col s6">
                <h3>Welcome</h3>
            </div>
        </div>
    </div>
</div>

<?php include ('includes/footer.html');
?>

你好,

由于某种原因,我的标题不起作用。

我的项目包含这些目录

根 --index.php - /登录 ----index.php --/包括 ----header.html ----config.inc.php

我的 index.php 正确显示了 header 并完美地继承了配置文件,但是登录文件夹中的 index.php 不包含 header。 它确实包含配置(需要)。

我尝试了几种方法,例如 $_server['DOCUMENT_ROOT'] 之类的东西,但我无法显示该标题。

【问题讨论】:

    标签: php html header include require


    【解决方案1】:

    只需将文件 *.html 重命名为 *.php

    比如header.php、footer.php

    【讨论】:

      【解决方案2】:

      嘿,试试在正斜杠前加一个句号,也试试不加句号或正斜杠

      <?php
      
      require('./includes/config.inc.php');
      include ('./includes/header.html');
      $page_name = NAME;
      
      $page_title = 'Home';
      ?>
      
      <div  style="background-color:green;" class="container">
          <div class="section">
              <div class="row">
                  <div class="col s6">
                      <h3>Welkom</h3>
                  </div>
                  <div class="col s6">
                      <h3>Welcome</h3>
                  </div>
              </div>
          </div>
      </div>
      
      <?php include ('includes/footer.html');
      ?>
      

      【讨论】:

        【解决方案3】:
        < ?php include 'header.php'; ?>
        
        ALL YOUR CONTENT HERE
        
        < ?php include 'footer.php'; ?>
        

        请查看此链接:-https://css-tricks.com/forums/topic/how-to-include-php-headers-and-footers-on-html-site/

        【讨论】:

          猜你喜欢
          • 2016-02-15
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-05-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多