How to Check String is URL or Not in Laravel?
Hi Folks,
Today, I will let you know example of laravel check string is url. if you want to see an example of how to check string is url or not in laravel then you are in the right place. you can see laravel string is url or not example. you'll learn laravel Str::isUrl() helper. Let's get started with laravel str isurl helper example.
The Str::isUrl() function in Laravel is used to check if the given string is a valid URL. Here is an example of how to use the Str::isUrl() function:
In this example, the Str::isUrl() function will return true if the $url string is a valid URL format, and false otherwise.
let's see the simple example:
Laravel Check String is URL or Not 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)
{
$isUrl = Str::isUrl('https://www.itsolutionstuff.com');
dd($isUrl);
}
}
Output:
true
Laravel Check String is URL or Not in Blade File
you can use it with blade file like this way:
Blade File Code:
<p>{{ Str::isUrl('https://www.itsolutionstuff.com') }}</p>
Output:
true
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
- How to Convert String to CamelCase in Laravel?
- How to Get Length of String in Laravel?
- Laravel Convert String to Uppercase Example
- Laravel Convert String to Lowercase Example
- 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?
- How to Add Dynamic Carousel Slider in Laravel?
- How to Install and Use Laravel Debugbar?
- Laravel PayPal Send Payment to Email Example