I wrote the original code as follows:
function The_lan_ip () {//
if (!is_windows_os ()) {//If it is not the Windows operating system, perform ifconfig to catch the corresponding IPV4 IP
EXEC (' ifconfig ', $output);
for ($i = 0; $i <= count ($output); $i + +) {
error_reporting (0);
Preg_match ('/\inet.*:(. *) \040/', $output [$i], $the _ip_str); Through the regular to find inet corresponding IP address is the LAN IP
if (count ($the _ip_str) > 0) {
$the _lan_ip[$i] = $the _ip_str[1];
}
}
} else {exec (' ipconfig ', $output);//If it is a Windows operating system, execute ipconfig to catch the corresponding IPV4 IP
for ($i = 0; $i <= count ($output); $i + +) {
error_reporting (0);
Preg_match ('/\ipv4.*:(. *)/', $output [$i], $the _ip_str); Through the regular to find IPv4 corresponding IP address is the LAN IP
if (count ($the _ip_str) > 0) {
$the _lan_ip[$i] = $the _ip_str[1];
}
}
}
Return ($the _lan_ip);
}
The above describes the PHP to get the LAN IP function, is not very useful, which God help to optimize a bit, including the content, I hope that the PHP tutorial interested in a friend helpful.