In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to write PHP JS Ip address and domain name format detection code", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to write PHP JS Ip address and domain name format detection code"!
PHP IP address format detection function
The copy code is as follows:
Function checkIp ($ip) {
$ip = str_replace (",", $ip)
$ip = strtolower ($ip)
$ip= str_replace ("http://",", $ip)
$ip= str_replace ("https://",", $ip)
If (preg_match ('/ [AmurZamurzhuang -] /', $ip)) {
If (preg_match ('/ ^ ([\ w -] +\.) + ((com) | (net) | (org) | (gov\ .cn) | (info) | (cc) | (net\ .cn) | (org\ .cn) | (name) | (biz) | (tv) | (cn) | (mobi) | (name) | (sh) | (ac) | (io) | (tw) | (com\ .tw) | (hk) | (com\ .HK) | (ws) | (travel) | (tm) | (la) | (me\ .uk) | (org\ .uk) | (ltd\ .uk) | (plc\ .uk) | (in) | (eu) | (it) | (jp) | (co) | (me) | (mx) | (ca) | (ag) | (com\ .co) | (net\ .co) | (nom\ .co) | (com\ .ag) | ( Net\ .ag) | (fr) | (org\ .ag) | (am) | (asia) | (at) | (be) | (bz) | (com\ .bz) | (net\ .bz) | (net\ .br) | (com\ .br) | (de) | (es) | (com\ .es) | (nom\ .es) | (org\ .es) | (fm) | (gs) | (co\ .in) | (firm\ .in) | (gen\. In) | (ind\ .in) | (org\ .in) | (jobs) | (ms) | (com\ .mx) | (nl) | (nu) | (co\ .nz) | (net\ .nz) | (org\ .nz) | (tc) | (tk) | (org\ .tw) | (idv\ .tw) | (co\ .uk) | (vg) | (ad) | (ae) | (af) | (ai) | (al) | | (an) | (ao) | (aq) | (as) | (au) | (aw) | (az) | (ba) | (bb) | (bd) | (bf) | (bg) | (bh) | (bi) | (bm) | (bn) | (bo) | (br) | (bs) | (bt) | (bv) | (bw) | (by) | (cd) | (cf) | (cg) | (ch) | (ci) | | | (ck) | (cl) | (cm) | (cu) | (cv) | (cx) | (cy) | (cz) | (dj) | (dk) | (dm) | (do) | (dz) | (ec) | (eg) | (er) | (et) | (fi) | (fj) | (fk) | (fo) | (ga) | (gd) | (ge) | (gf) | (gg) | (gh) | (gi) | | | (gl) | (gm) | (gn) | (gq) | (gr) | (gt) | (gu) | (gw) | (gy) | (hm) | (hn) | (hr) | (ht) | (hu) | (ie) | (il) | (im) | (iq) | (ir) | (is) | (je) | (jm) | (jo) | (ke) | (kg) | (kh) | (ki) | (km) | | | (kn) | (kr) | (kw) | (kz) | (lb) | (lc) | (li) | (lk) | (lr) | (ls) | (lt) | (lu) | (lv) | (ly) | (mc) | (md) | (mg) | (mh) | (mk) | (ml) | (mm) | (mn) | (mo) | (mp) | (mq) | (mr) | (mt) | (mu) | | | (mv) | (mw) | (my) | (mz) | (na) | (nc) | (ne) | (nf) | (ng) | (ni) | (no) | (np) | (nr) | (nz) | (om) | (pa) | (pe) | (pf) | (pg) | (ph) | (pl) | (pm) | (pn) | (pr) | (ps) | (pt) | (pw) | (py) | (qa) | | | (re) | (ro) | (ru) | (sa) | (sb) | (sc) | (sd) | (se) | (sg) | (si) | (sk) | (sl) | (sm) | (sn) | (st) | (sv) | (sy) | (sz) | (td) | (tf) | (tg) | (th) | (tj) | (tl) | (tn) | (to) | (tr) | (tt) | | | (tz) | (ua) | (ug) | (uk) | (uy) | (uz) | (va) | (vc) | (ve) | (vi) | (vn) | (vu) | (wf) | (ye) | (yt) | (yu) | (za) | (zm) | (zw)) $/ i' | $ip)) {
Return true
} else {
Return false
}
} else {
$ipArray = explode (".", $ip)
$j = count ($ipArray)
If ($jacks 4)
{
Return false
}
For ($ifolio, share i255) {
Return false
}
}
Return true
}
}
JS Code:
The copy code is as follows:
Function checkIP () {
Var ipArray,ip,j
Ip = document.ipform.ip.value
If (ip.indexOf ("") > = 0) {
Ip = ip.replace (/ / g, "")
Document.ipform.ip.value = ip
}
If (ip.toLowerCase (). IndexOf ("http://")==0){
Ip = ip.slice (7)
Document.ipform.ip.value = ip
}
If (ip.toLowerCase (). IndexOf ("https://")==0){
Ip = ip.slice (8)
Document.ipform.ip.value = ip
}
If (ip.slice (ip.length-1) = = "/") {
Ip = ip.slice (0Legend ip.futhmur1)
Document.ipform.ip.value = ip
}
If (/ [AmurZaMuzhuang -] / .test (ip)) {
If (! / ^ ([\ w -] +\.) + (com) | (net) | (org) | (gov\ .cn) | (info) | (cc) | (com\ .cn) | (net\ .cn) | (org\ .cn) | (name) | (biz) | (tv) | (mobi) | (name) | (sh) | (ac) | (io) | (tw) | (com\ .tw) | (hk) | (com\. Hk) | (ws) | (travel) | (us) | (la) | (me\ .uk) | (org\ .uk) | (ltd\ .uk) | (plc\ .uk) | (in) | (eu) | (it) | (jp) | (co) | (me) | (mx) | (ca) | (ag) | (com\ .co) | (net\ .co) | (nom\ .co) | (com\ .ag) | (net\ .ag) ) | (fr) | (org\ .ag) | (am) | (asia) | (at) | (be) | (bz) | (com\ .bz) | (net\ .bz) | (net\ .br) | (com\ .br) | (de) | (es) | (com\ .es) | (nom\ .es) | (org\ .es) | (fm) | (co\ .in) | (firm\ .in) | (gen\ .in) | Ind\ .in) | (net\ .in) | (org\ .in) | (jobs) | (ms) | (com\ .mx) | (nl) | (nu) | (co\ .nz) | (net\ .nz) | (org\ .nz) | (tc) | (tk) | (org\ .tw) | (idv\ .tw) | (co\ .uk) | (vg) | (ad) | (ae) | (af) | (ai) | (al) | (an) | | (ao) | (aq) | (ar) | (au) | (aw) | (az) | (ba) | (bb) | (bd) | (bf) | (bg) | (bh) | (bi) | (bj) | (bn) | (bo) | (br) | (bs) | (bt) | (bv) | (bw) | (by) | (cd) | (cf) | (cg) | (ch) | (ci) | (ck) | | | (cl) | (cm) | (cr) | (cv) | (cx) | (cy) | (cz) | (dj) | (dk) | (dm) | (do) | (dz) | (ec) | (ee) | (er) | (et) | (fi) | (fj) | (fk) | (fo) | (ga) | (gd) | (ge) | (gf) | (gg) | (gh) | (gi) | (gl) | | | (gm) | (gn) | (gp) | (gr) | (gt) | (gu) | (gw) | (gy) | (hm) | (hn) | (hr) | (ht) | (hu) | (id) | (il) | (im) | (iq) | (ir) | (is) | (je) | (jm) | (jo) | (ke) | (kg) | (kh) | (ki) | (km) | (kn) | | | (kr) | (kw) | (ky) | (lb) | (lc) | (li) | (lk) | (lr) | (ls) | (lt) | (lu) | (lv) | (ly) | (ma) | (md) | (mg) | (mh) | (mk) | (ml) | (mm) | (mn) | (mo) | (mp) | (mq) | (mr) | (mt) | (mu) | (mv) | | | (mw) | (my) | (mz) | (na) | (nc) | (ne) | (nf) | (ng) | (ni) | (no) | (np) | (nr) | (nz) | (om) | (pa) | (pf) | (pg) | (ph) | (competitive) | (pm) | (pn) | (pr) | (ps) | (pt) | (pw) | (py) | (qa) | (re) | | | (ro) | (ru) | (rw) | (sb) | (sc) | (sd) | (se) | (sg) | (si) | (sk) | (sl) | (sm) | (sn) | (sr) | (sv) | (sy) | (sz) | (td) | (tf) | (tg) | (th) | (tj) | (tl) | (tn) | (to) | (tr) | (tt) | (tz) | | | (ua) | (ug) | (uk) | (uy) | (uz) | (va) | (vc) | (ve) | (vi) | (vn) | (vu) | (wf) | (ye) | (yt) | (yu) | (za) | (zm) | (zw) $/ i.test (ip)) {
Alert ("incorrect domain name")
Document.ipform.ip.focus ()
Return false
}
}
Else {
IpArray = ip.split (. ")
J = ipArray.length
If (jacks 4)
{
Alert ("incorrect IP")
Document.ipform.ip.focus ()
Return false
}
For (var item0, witch i255)
{
Alert ("incorrect IP")
Document.ipform.ip.focus ()
Return false
}
}
}
}
Thank you for your reading, the above is the content of "how to write PHP JS Ip address and domain name format detection code". After the study of this article, I believe you have a deeper understanding of how to write PHP JS Ip address and domain name format detection code, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.