在codeigniter中,我创建了一个视图,该视图在另一个视图中调用,但该视图未显示在特定的div中。此视图显示在 head 标记下。我使用了以下示例中的代码
<div class='test-view'>
<?php $this->load->view('abc') ?>
</div>
这段代码以前可以工作,但不幸的是,linex 服务器被重建了。我不知道服务器内部出了什么问题或给我错误的代码。任何人都可以帮助我为什么这段代码出现在div 之外?服务器上缺少哪个扩展或模块。(对不起,英语不好)。
谢谢
注意:- 如果我在 PHP 代码中使用任何 html,这些 html 也没有显示在特定的div 中。喜欢
<div class="for-test">
<?php $html = '<span>This is only for example. <a href="#">Not a real work</a>.</span>';
$echo $html;
?>
</div>
上面的代码也没有显示在<div class="for-test"></div>
添加分号行尾
<?php $this->load->view('abc'); ?>
为视图添加参数 TRUE
<div class='test-view'>
<?php $this->load->view('abc', NULL, TRUE) ?>
</div>
https://ellislab.com/codeigniter/user-guide/general/views.html
主题:将视图作为数据返回
尝试这样做:将视图作为数据发送到视图。就像这样
//in the controller
$data['forTestContent'] = $this->load->view('yourView', NULL, TRUE);
$this->load->view ('yourView', $data);
//In the view just use
<div class='test-view'><?= $forTestContent; ?></div>