首页 > 解决方案 > 如何在 PHP 和 CodeIgniter 中的页眉和页脚之间显示 html 文件

问题描述

                <?php
                defined('BASEPATH') OR exit('No direct script access allowed');
                //error_reporting(0);
                $this->load->view('layouts/topmenu.php', $metaData);
                //echo $emailid;
                //exit;
                ?>
                //I would like to display an HTML file here
                 <a href=""></a>
                <?php $this->load->view('layouts/bottom'); ?>
                <?php $this->load->view('layouts/footer'); ?>

我想显示一个页眉和页脚页面,它们之间有一个 html 文件,该文件位于 .html 文件中。

如何在 PHP 代码中显示 .html 文件?

标签: phphtmlcodeigniter

解决方案


Codeigniter 的好处之一是这很容易做到,并且有多种方法可以做到

由于看起来问题在于您需要调用的视图是 html 文件而不是 php 文件,因此您只需将 html 文件放在您的views目录中并加载它,指定文件扩展名:

$this->load->view('layouts/file.html');

这就是它的全部


推荐阅读