The result obtained from the previous IP address is not perfect. The reason is that the IP Address Resolution of ip138 is not very detailed in dealing with foreign addresses, So I re-wroteCode.
<! Doctype html >
< HTML Lang = " En " >
< Head >
< Title > </ Title >
< Meta charset = " UTF-8 " />
< Meta name = " Author " Content = "" />
< Meta name = " Keywords " Content = "" />
< Meta name = " Description " Content = "" />
</ Head >
< Body >
<? PHP
$ Ipaddr = " 4.4.44.4 " ;
$ Ipchinazaddr = " Http://tool.chinaz.com/IP? IP = " . $ Ipaddr ;
$ Contents = File_get_contents ( $ Ipchinazaddr );
$ Pattern = " /\=\\>\>. + \ <\/Strong \> \ <br \/\>/ " ;
$ String = $ Contents ;
Preg_match_all ( $ Pattern , $ String , $ Addrarray );
$ Num = Count ( $ Addrarray [ 0 ]);
$ Pattern = " /(==>>). + (==>>> \ S )/ " ;
For ( $ I = 0 ; $ I < $ Num ; $ I ++ ){
$ Addrarray [ 0 ] [ $ I ] = Preg_replace ( $ Pattern , "" , $ Addrarray [ 0 ] [ $ I ]);
}
Echo " <PRE> " ;
Print_r ( $ Addrarray );
Echo " </PRE> " ;
?>
</ Body >
</ Html >
Satisfactory results
The above are two codes written by myself to obtain the physical IP address. As a beginner, it is quite interesting to write simple code when it is okay. After all, I am a beginner and cannot pay more attention to security, space utilization, time efficiency, and other issues. I hope you can leave your footprints here. Thank you, younger brother.