preg_match vs parse_url

Run Settings
LanguagePHP
Language Version
Run Command
<?php $url1 = '//google.com'; $url2 = 'http://google.com'; $url3 = 'https://google.com'; $url4 = 'google.com'; $email = 'some@email.com'; if( 1 === preg_match( '|^https?://|', $url1 ) ){ echo "url1 preg_matched\n"; } if( 1 === preg_match( '|^https?://|', $url2 ) ){ echo "url2 preg_matched\n"; } if( 1 === preg_match( '|^https?://|', $url3 ) ){ echo "url3 preg_matched\n"; } if( 1 === preg_match( '|^https?://|', $url4 ) ){ echo "url4 preg_matched\n"; } if( 1 === preg_match( '|^https?://|', $email ) ){ echo "email preg_matched\n"; } echo "url1: "; var_dump( parse_url( $url1 ) ); echo "url2: "; var_dump( parse_url( $url2 ) ); echo "url3: "; var_dump( parse_url( $url3 ) ); echo "url4: "; var_dump( parse_url( $url4 ) ); echo "email: "; var_dump( parse_url( $email ) );
Editor Settings
Theme
Key bindings
Full width
Lines