Call to undefined function str_limit()

19.5k views Asked by At

Call to undefined function str_limit() laravel 6x this my code , help me

<dt>Description</dt>
<dd style="word-break: break-all;"> {{ str_limit($product ?? '',500,' ...') }}</dd>

7

There are 7 answers

1
AudioBubble On BEST ANSWER

If you are using laravel 5.4 upwards

Please use this like

{{ \Illuminate\Support\Str::limit($product ?? '',500,' ...') }}

See Laravel Tutorial for more info.

0
hackernewbie On

In order to use Laravel helper functions, you need to first install laravel helpers, using the following command:

composer require laravel/helpers
0
Safaetul Ahasan Piyas On

Here is your solution. I hope it has helped you:

{{\Illuminate\Support\Str::limit($product, 500)}}
0
user33192 On

Or we can do it in simple Vanilla PHP way...

substr($string_here, 0, 100) //100 as the limit

For rich text, we can do...

substr(strip_tags($string_here), 0, 100)
1
Mehedi Hasan On

str_* and array_* helper functions removed from Laravel 6.* So try to use there class instead of global functions.

Or you can install https://github.com/laravel/helpers package to get both of these types functions.

2
TsaiKoga On

In version 5.8+ str helpers got removed you must use Illuminate\Support\Str::limit($string) instead

Try this one:

{{ \Illuminate\Support\Str::limit($product, 500, '...') }}
0
mafortis On

Just install laravel helpers

composer require laravel/helpers

Repository