php check if string is valid url code example
Example 1: check if valid url php
filter_var($url, FILTER_VALIDATE_URL);
Example 2: php check if string contains url
preg_match('/(http|ftp|mailto)/', $string, $matches);
var_dump($matches);
filter_var($url, FILTER_VALIDATE_URL);
preg_match('/(http|ftp|mailto)/', $string, $matches);
var_dump($matches);