Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skater's avatar

What is Str::lower for ?

Well, it's not the exact question. The easy answer is "to convert to lowercase a string".

But... What is this for? Str::lower('LARAVEL'); If we have already PHP... strtolower('LARAVEL');

Easy answer is "if you don't like it don't use that helper" ... ok, thank you ;-) I will sleep well tonight ... but I want to know if there's something I miss to understand the existence of some helpers, like for example Str::lower.

I've seen a lot of helpers that basically does the SAME than the original PHP function.

What is their true purpose ?

Thank you

0 likes
2 replies
Niush's avatar

Str::lower('LARAVEL') under the hood becomes mb_strtolower('LARAVEL', 'UTF-8') which will convert all UTF-8 characters to lowercase (e.g. Polish language characters).

There are many other helpers: https://laravel.com/docs/9.x/helpers#strings-method-list

And, adding a few lower, upper, length etc. won't hurt. It makes code clear, easy to write and consistent.

Similarly, PHP functions can be confusing. Example we use str_​starts_​with but for lower case we are provided with strtolower not str_to_lower. While, Str::lower and Str::startsWith is consistent.

1 like

Please or to participate in this conversation.