# PHP验证码 **Repository Path**: lushaoming/php-captcha ## Basic Information - **Project Name**: PHP验证码 - **Description**: 简单的验证码生成工具,支持简单字符(字母数字)和简单的数学计算(两位数以内的加减乘除,乘法不会两个数字都是两位数,除法是必须整除) - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-28 - **Last Updated**: 2024-11-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: 验证码 ## README # PHP验证码生成器 ## 要求 - PHP >= 8.1 - gd2 - mbstring ## 安装 ```bash composer require yolo/captcha ``` ## 使用 ```php 50, 'width' => 250, 'length' => 6, // only for character engine 'font' => __DIR__ . '/fonts/Arial.ttf', 'fontSize' => 25, 'quality' => 0, // 0-9, No effect now 'backgroundColor' => [255, 255, 255], 'fontColor' => [0, 0, 0], // No effect now 'engine' => CaptchaEngine::CHARACTER, // or CaptchaEngine::SIMPLE_ARITHMETIC ]); $captcha = new Captcha(); $image = $captcha->createCaptcha(); imagepng($image, __DIR__ . '/captcha.png'); // Set the content type and output the image //header('Content-Type: image/png'); //imagepng($image); $captcha->destroyCaptcha($image); // Get the captcha answer $answer = $captcha->getCaptchaAnswer(); ```