Before https://laravel.com/docs/9.x/releases, when you wanted to interact with strings you would either use the Illuminate\Support\Str class like so. use Illuminate\Support\Str; $result = Str::endsWith('PHP is awesome', 'PHP'); // Outputs: true Or if you want to do these string operations fluently, you can use the Illuminate\Support\Str::of that returns the instance of Illuminate\Support\Stringable class like so.

Laravel 9 now comes with a new str() helper function globally that you can use to do string operations fluently just like how you would do with Str::of.

As you can tell, the one advantage this helper method brings is now you don’t have to import the Illuminate\Support\Str class altogether.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners