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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners