次のようなparse_url()
パラメータで使用します。PHP_URL_SCHEME
$scheme = parse_url( $url, PHP_URL_SCHEME);
if( !in_array( $scheme, array( 'http', 'https'))){
// Wrong URL
}
// Good URL
コメント後:
if( strncmp( $url, 'http://', 7)){ // 7 = strlen( 'http://')
// Not secured
} else if (strncmp( $url, 'https://', 8)) {
// Secured
} else if ( strpos($url, '://') !== false){
// ftp://, sftp:// and other protocols
// you may do this also by: preg_match and regexp ~^[\w]+://~i - will be more accurate
} else {
// any other URL, www.google.com and so on...
// auto-assue: not secured
}