ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
# swoole\_get\_local\_ip [TOC] 此函数用于获取本机所有网络接口的IP地址 ## 函数原型 ~~~ array swoole_get_local_ip(); ~~~ ## 返回值 返回当前机器的所有网络接口的IP地址 ## 使用示例 ~~~ <?php // 获取本机所有网络接口的IP地址 $list = swoole_get_local_ip(); print_r($list); /** 返回值 Array ( [eno1] => 10.10.28.228 [br-1e72ecd47449] => 172.20.0.1 [docker0] => 172.17.0.1 ) **/ ~~~ ## 注意事项 * 目前只返回IPv4地址,返回结果会过滤掉本地loop地址127.0.0.1。 * 结果数组是以interface名称为key的关联数组。比如 array("eth0" => "192.168.1.100") * 此函数会实时调用`ioctl`系统调用获取接口信息,底层无缓存