FuelPhp解码视图中的HTML实体
现在,我正在使用HTML_entity_decode在视图中显示HTML:FuelPhp解码视图中的HTML实体,php,fuelphp,Php,Fuelphp,现在,我正在使用HTML_entity_decode在视图中显示HTML: <strong>Body:</strong> <?php echo html_entity_decode($post->body); ?></p> 我阅读了文档并尝试: public function action_view($id = null) { $data['post'] = Model_Post::find($id);
<strong>Body:</strong>
<?php echo html_entity_decode($post->body); ?></p>
我阅读了文档并尝试:
public function action_view($id = null)
{
$data['post'] = Model_Post::find($id);
is_null($id) and Response::redirect('Post');
$this->template->title = "Post";
$this->template->content = View::forge('post/view', $data);
View::$auto_encode = false;
}
但这只是给了我一个“访问未声明的静态属性”的权限。很明显,我做错了…因为我可以看到您没有正确设置自动编码 试试这个,看看它是否是你想要的
public function action_view($id = null)
{
$view = View::forge('post/view');
is_null($id) and Response::redirect('Post');
$post = Model_Post::find($id);
$view->set('post', $post, false); //Here the auto_encode is set to false
$this->template->title = "Post";
$this->template->content = $view;
}
希望这有帮助,因为我可以看到您没有正确设置自动编码 试试这个,看看它是否是你想要的
public function action_view($id = null)
{
$view = View::forge('post/view');
is_null($id) and Response::redirect('Post');
$post = Model_Post::find($id);
$view->set('post', $post, false); //Here the auto_encode is set to false
$this->template->title = "Post";
$this->template->content = $view;
}
希望这有帮助有很多方法可以做到这一点:
protected $this->auto_encode = false;
控制器中的该属性将停止对所有指定值进行编码
否则,请使用以下命令:
$this->template->set('title', "Post", false);
$this->template->set('content', $view, false);
这将停止对特定值进行编码。有很多方法可以做到这一点:
protected $this->auto_encode = false;
控制器中的该属性将停止对所有指定值进行编码
否则,请使用以下命令:
$this->template->set('title', "Post", false);
$this->template->set('content', $view, false);
这将停止正在编码的特定值