Source Code:
(back to article)
<?php $website = 'https://www.w3docs'; $pattern = '/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([\/\w.-]*)*\/?$/'; if (!preg_match($pattern, $website)) { echo "Invalid URL"; } else { echo "URL is valid: " . $website; } ?>
Result:
Report an issue