PHP code example of phpu / think-captcha
1. Go to this page and download the library: Download phpu/think-captcha 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/ */
phpu / think-captcha example snippets
public function captcha(){
return ThinkCaptcha::printImg(); // png图片
// return ThinkCaptcha::printBase64(); // Base64
}
public function check($code){
if (false === ThinkCaptcha::check($code)){
return response('验证码输入错误',200);
}else{
return response('验证码输入正确',200);
}
}
/**
* 配置文件中提供独立配置,
* 如果无效果建议将配置文件config.php改名为phpu_captcha.php移入项目配置目录内!
*/
public function captcha(){
return ThinkCaptcha::configure('sign')->printImg();
}