Answers for "laravel check if string is url"

PHP
0

laravel check if string is url

if (filter_var($string, FILTER_VALIDATE_URL)) { 
  // you're good
}
Posted by: Guest on July-06-2021
0

laravel check if string is url

<?php 
    $regex = "((https?|ftp)\:\/\/)?"; // SCHEME 
    $regex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // User and Pass 
    $regex .= "([a-z0-9-.]*)\.([a-z]{2,3})"; // Host or IP 
    $regex .= "(\:[0-9]{2,5})?"; // Port 
    $regex .= "(\/([a-z0-9+\$_-]\.?)+)*\/?"; // Path 
    $regex .= "(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?"; // GET Query 
    $regex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?"; // Anchor 

       if(preg_match("/^$regex$/i", $url)) // `i` flag for case-insensitive
       { 
               return true; 
       } 
?>
Posted by: Guest on July-06-2021

Code answers related to "laravel check if string is url"

Browse Popular Code Answers by Language