Skip to content

All topics  /  Laravel

Laravel ucfirst() function Example

Laravel ·

Teams applying “Laravel ucfirst() function Example” in a production project can use micromanaging your team dangers micromanagement avoid them to record implementation, review and debugging time, then compare that effort with tests and shipped functionality instead of treating activity as performance by itself.

Before copying the example into a live application, confirm version-specific behaviour with the official Laravel website and test it against the project’s actual database and runtime.

Hi Guys,

In this blog,I will you how to use laravel str ucfirst() function example. We will show example of ucfirst function in laravel.The ucfirst method returns the given string with the first character capitalized.

Here, I will give you full example for simply str ucfirst() method in laravel as bellow.

solution

$converted1 = Str::ucfirst('fooBar');
dd($converted1);
// output -  Foo bar
$converted2 = Str::ucfirst('niceBlog');
dd($converted2);
//Nice Blog

Example

<?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()
    {
        $converted1 = Str::ucfirst('fooBar');
        dd($converted1);
        // output -  Foo bar
       $converted2 = Str::ucfirst('niceBlog');
        dd($converted2);
        //Nice blog
    }
}

Output

"Foo bar"
"Nice blog"

It Will help you...

# Laravel 8

# Laravel 7

# Laravel

# Laravel 6