PHP code example of alone-webman / ip

1. Go to this page and download the library: Download alone-webman/ip library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alone-webman / ip example snippets


return [
    '@' => [
        //白名单 string|array
        alone_mid_ip_white("IP列表(支持ipv4,ipv6)"),
        //黑名单 string|array
        alone_mid_ip_black("IP列表(支持ipv4,ipv6)")
    ]
];

    /**
     * 判断白名单ip列表
     * @param string       $ip   要判断的ip
     * @param array|string $list 允许ip列表
     * @param bool         $type 是否允许IP段,使用[0-255],全部使用*
     * @return bool true=允许访问,false=禁止访问
     */
alone_ipv4(string $ip, array|string $list, bool $type = true): bool


    /**
     * 判断ipv6列表
     * @param string       $ip   要判断的ip
     * @param array|string $list 允许ip列表
     * @param bool         $type 是否允许IP段,使用[0-ffff],全部使用*
     * @return bool true=允许访问,false=禁止访问
     */
alone_ipv6(string $ip, array|string $list, bool $type = true): bool