我正在 codeigniter 中使用 TinyMCE 进行内容输入。但是输出源如下所示,不显示 < 和 >。相反,它显示 HTML 实体,如 &lessthan; 并且&大于; 等等
该条目由管理员在登录后进行。
输出来自数据库。
我在模型中取出了逃生,但它仍然做同样的事情。
我还有一个配置设置, $config['global_xss_filtering'] = FALSE;
所以我想添加html_entity_decode。但是 $page_data 是一个数组。该数组具有用于页面项目的 id、title、content 和 slug。
谁能告诉我该怎么做?
输出示例:
<p><img src="images/icon1.png" border="0"
alt="icon" width="48" height="48" />
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
型号代码:
<?php
class Pagemodel extends Model
{
....
...
/**
* Return an array of a page — used in the front end
*
* @access public
* @param string
* @return array
*/
function fetch($slug)
{
$query = $this->db->query("SELECT * FROM `pages` WHERE `slug` = '$slug'");
return $query->result_array();
}
...
...
}
?>
控制器代码:
function index()
{
$page_slug = $this->uri->segment('2'); // Grab the URI segment
if($page_slug === FALSE)
{
$page_slug = 'home';
}
$page_data = $this->pages->fetch($page_slug); // Pull the page data from the database
if($page_data === FALSE)
{
show_404(); // Show a 404 if no page exists
}
else
{
$this->_view('index', $page_data[0]);
}
}