Home >Backend Development >PHP Tutorial >Detailed explanation of how to implement rotated image verification in PHP
This article brings you relevant knowledge about PHP. It mainly introduces how PHP implements rotation image verification. Let’s take a look at it together. I hope it will be helpful to everyone.
composer require kkokk/poster
composer update kkokk/poster
Open source repository:
gitee documentation
github document
use Kkokk\Poster\PosterManager; use Kkokk\Poster\Exception\PosterException; try { # 旋转图片自定义参数 $params = [ 'src' => '', // 背景图片,尺寸 350 * 350 正方形都可 'im_width' => 350, // 画布宽度 'im_height' => 350, // 画布高度 ]; $type = 'rotate'; /** * 获取验证参数 * 内部使用了 laravel 的 cache 缓存,返回的是图片的 base64 、 缓存key * @param string $type 验证码类型 * @param array $params 验证码自定义参数 * @return arary */ $data = PosterManager::Captcha()->type($type)->config($params)->get(); /** * 验证 * 前端根据相关Detailed explanation of how to implement rotated image verification in PHP操作进行处理, 返回旋转角度,返回 true 则验证成功 * @param string $key 缓存key * @param string|int $value 前端传回来的旋转角度 * @param int $leeway 误差值 * @return boolean */ $res = PosterManager::Captcha()->type($type)->check($key, $value, $leeway); } catch (PosterException $e) { print_r($e->getMessage()) }
ui imitation Baidu statistics
Recommended study:《PHP video tutorial》
The above is the detailed content of Detailed explanation of how to implement rotated image verification in PHP. For more information, please follow other related articles on the PHP Chinese website!