Home >Backend Development >PHP Tutorial >The function of getting the LAN IP in PHP is not very easy to use. Can any expert help to optimize it?

The function of getting the LAN IP in PHP is not very easy to use. Can any expert help to optimize it?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 09:06:11896browse

The original code I wrote is as follows:

function the_lan_ip() {//

if (!is_windows_os()) { //If it is not a windows operating system, execute ifconfig to capture the corresponding IPv4 IP
exec('ifconfig' , $output);
for ($i = 0; $i <= count($output); $i++) {
error_reporting(0);
preg_match('/inet.*:(.*)
The above introduces the function of PHP to get the LAN IP. It is not very easy to use. Can any expert help optimize it, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn