如果一个字符串是这样的:
$str = "This is a\n\nstring!"
我在 Codeigniter 中加载了排版类,并像这样使用它:
<?=auto_typography($str)?>
HTML 输出不应该是:
<p>This is a</p>
<p>string!</p>
为什么我不断收到:
<p>This is a\n\nstring!</p>
我如何实现我想要的?谢谢!
控制器:
public function show($strId)
{
$this->load->helper('segment3');
$this->load->helper('typography');
$this->load->model('segment3/Default_model');
$data['head'] = $this->Default_model->segment3();
$data['segment3'] = $this->Default_model->segment3();
$this->load->view('head_view', $data);
$this->load->view('header_view', $data);
$this->load->view('segment3/__mainContent/default_view', $data);
$this->load->view('footer_view', $data);
}
看法:
<?php if (isset($segment3)):?>
<?php foreach ($segment3 as $row):?>
<h1><?=$row->title?></h1>
<img src="/images/<?=$row->strId?>.jpg" class="scale-with-grid">
<?=auto_typography($row->__mainContent)?>
<?php endforeach;?>
<?php endif;?>
$row->__mainContent 是从数据库中提取的...