How to check if current url is valid in laravel?

by arnoldo.moen , in category: PHP Frameworks , 10 months ago

How to check if current url is valid in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by denis , 7 months ago

@arnoldo.moen 

In Laravel, you can use the URL::isValidUrl() method to check if a given URL is valid. Here's an example of how to check if the current URL is valid:

1
2
3
4
5
6
7
8
9
use IlluminateSupportFacadesURL;

$currentUrl = URL::current();

if (URL::isValidUrl($currentUrl)) {
    echo "The current URL is valid.";
} else {
    echo "The current URL is not valid.";
}


This code will check if the current URL is valid and display a message accordingly.

Related Threads:

How to check current user in laravel?
How to check current date record in laravel?
How to check if decimal is valid value in teradata?
How to check and control previous url in laravel?
How to check if a file exists in a url in laravel?
How to check if the current time is between two times using moment.js?