Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.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
Php 拉威尔博客文章样本_Php_Laravel 5 - Fatal编程技术网

Php 拉威尔博客文章样本

Php 拉威尔博客文章样本,php,laravel-5,Php,Laravel 5,我正在尝试制作一个系统,将博客文章发布到我的网页上,我可以让它显示数据库中的内容,但是如果我想限制要显示的字符数量的话 @foreach ($pages as $post) <div class="post"> <h4>{{ $post->title}}</h4> <?php $content = html_entity_decode($post->body);

我正在尝试制作一个系统,将博客文章发布到我的网页上,我可以让它显示数据库中的内容,但是如果我想限制要显示的字符数量的话

@foreach ($pages as $post)
    <div class="post">
        <h4>{{ $post->title}}</h4>
        <?php
            $content = html_entity_decode($post->body); 
        ?>
        <p>{!!html_entity_decode($post->body)!!}</p>
        <p>{{ str_limit($content, $limit = 300, $end = '...') }}</p>
    <div>
@endforeach
@foreach($post形式的页面)
{{$post->title}
{!!html\u实体\u解码($post->body)!!}

{{str_limit($content,$limit=300,$end='…')}

@endforeach

因此,第一个
标记可以工作,但字符不受限制,第二个将限制字符的数量,但它将与HTML标记一起显示。我刚刚学习了laravel,所以我不确定为什么它不能正常工作。

为将来的任何人找到了答案,PHP有一个名为strip_tags()的函数