Laravel Convert String to Uppercase Example
Hey Guys,
In this tutorial, you will learn laravel string to uppercase. you can understand a concept of how to convert string to uppercase in laravel. I would like to show you laravel convert string to uppercase. you will learn laravel str upper helper.
Absolutely! To convert a string to uppercase using Laravel's Str::upper() method, follow these steps.
Remember to include the use Illuminate\Support\Str; statement at the top of your file to import the Str class before using the Str::upper() method. This method works similarly to the strtoupper() function, but it's provided as part of Laravel's helper methods.
let's see the simple example:
Laravel String to Uppercase in Controller
you can use it with controller like this way:
Controller Code:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$string = 'laravel 10';
$upper = Str::upper($string);
dd($upper);
}
}
Output:
LARAVEL 10
Laravel String to Uppercase in Blade File
you can use it with blade file like this way:
Blade File Code:
<p>{{ Str::upper('laravel 10') }}</p>
Output:
LARAVEL 10
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel Import Large CSV File Using Queue Example
- How to Replace String in Laravel?
- How to Install and Setup Supervisor in Ubuntu for Laravel?
- Laravel String Contains Case Insensitive Example
- Laravel Stripe Checkout Payment Integration Example
- How to Convert String to Array Conversion in Laravel?
- Laravel Delete All Records Older Than 7 Days Example
- Laravel Carbon diffForHumans() Example
- Laravel Update User Status Using Toggle Button Example
- How to Call Middleware from Controller in Laravel?
- Laravel Login with Username or Email Example