In this tutorial you will learn about the Laravel ucfirst() function Example and its application with practical example.
In this article, I’ll show you how to use laravel ucfirst() function with example. We will show example of ucfirst() function in laravel. In this tutorial, we will use ucfirst() function to convert given string to first character capitalized.
Laravel ucfirst() function
The ucfirst method returns the given string with the first character capitalized
Example:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Controllers\FileController; use Illuminate\Support\Str; class HomeController extends Controller { /** * Show the application dashboard. * * @return \Illuminate\Contracts\Support\Renderable */ public function index() { $str1 = Str::ucfirst('foo bar'); echo $str1."<br>"; $str2 = Str::ucfirst('laravel blog'); echo $str2; } } |
Output:-
1 2 |
Foo bar Laravel blog |