Last active
October 3, 2015 14:58
-
-
Save dfadler/2473954 to your computer and use it in GitHub Desktop.
Http and Https string Validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Checks a url string for http || https if its not there then http is applied | |
function validate_url_string( $url_string ) { | |
$pattern = '/^(http:\/\/|https:\/\/)/'; | |
preg_match( $pattern, $url_string, $matches ); | |
$url_string = count( $matches ) > 0 ? $url_string : 'http://'.$url_string; | |
return $url_string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment