PHP code example of xwx / common

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

    

xwx / common example snippets


$v = new Validate();
//添加验证条件
$v->addColumn('t1')
    ->ired()
    ->lenBetween(0, 10)
    ->url();
//进行参数验证
$r = $v->validate([
    't1' => '',
    't2' => 'http://baidu.com',
], true);

$xarr = XArray::funcIns($arr);
//链式数组处理
$r = $xarr->where('a', 1, '>')
    ->where('b', 1.1, '>')
    ->where('c', 1.1, '>')
    ->order('b', SORT_DESC)
    ->select(['a', 'd'])
    ->get();

$url = 'https://www.baidu.com';
$client = new WebClient($url);
$res = $client->get()
$return_string = $res->getBody();

$v = new \XWX\Common\XImage\VCode();
//保存图片到磁盘
//$v->funcCodeSave(rand(1000, 9999), 'D:/1.jpg');
//直接输入png图片
$v->funcCodeToPng(rand(1000, 9999));