Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
FuelPhp解码视图中的HTML实体_Php_Fuelphp - Fatal编程技术网

FuelPhp解码视图中的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);

现在,我正在使用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);

        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);
这将停止正在编码的特定值