Ec (2); & nbsp; the Code below copies the code functionmatchdomain ($ q) {preg_match ([a-z0-9] (w | }? [A-z0-9] | [a-z0-9]).) {1 ,} (aero | arpa | asia | biz | cat | com | coop | co | edu | gov | info | int | jobs | mil | mobi | mu script ec (2 ); script
The Code is as follows: |
|
Function matchdomain ($ q ){ Preg_match ('/([a-z0-9] (w | }? [A-z0-9] | [a-z0-9]).) {1 ,} (aero | arpa | asia | biz | cat | com | coop | co | edu | gov | info | int | jobs | mil | mobi | museum | name | net | org | pro | tel | travel | [a-z] [a-z]) (. [a-z] [a-z]) {0, 1}/', $ q, $ matches ); Return $ matches [0]; } |
// Instance application
The Code is as follows: |
|
$ Com = 'www .111cn.net '; Echo matchdomain ($ com ); // Www.111cn.net $ Cn = 'afdsafs '; Echo matchdomain ($ cn ); |
// Notice: undefined offset: 0 because it is not a domain name, so the domain name cannot be regressed, so an error occurs.