PHP code example of chenbool / verify

1. Go to this page and download the library: Download chenbool/verify 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/ */

    

chenbool / verify example snippets


use ChenBool\Verify;

$verify = new Verify();

// 判断是否为合法的 IP 地址
$ipv4 = $verify->isIPAddress('192.168.1.1');   // 返回 4
$ipv6 = $verify->isIPAddress('2001:0db8:85a3:0000:0000:8a2e:0370:7334'); // 返回 6
$invalid = $verify->isIPAddress('invalid');     // 返回 false

// 验证邮箱格式
$verify->isValidEmail('[email protected]');  // true
$verify->isValidEmail('invalid');            // false

// 判断是否为手机访问
$verify->isMobile();  // true 或 false

// 判断是否为微信访问
$verify->isWeiXin();  // true 或 false

// 判断是否为 HTTPS 请求
$verify->isHttps();   // true 或 false

// 检查手机号码格式(中国大陆手机号)
$verify->checkMobile('13800138000');  // true
$verify->checkMobile('1234567890');    // false

// 检查固定电话格式
$verify->checkTelephone('010-12345678');  // true
$verify->checkTelephone('0571-12345678'); // true
$verify->checkTelephone('12345678');      // false