尊龙凯时人生就是博

ÔõÑùÔÚThinkPHP6ÖоÙÐÐcaptchaͼÐÎÑéÖ¤Âë²Ù×÷£¿

Ëæ×Å»¥ÁªÍøµÄ¿ìËÙÉú³¤£¬»ùÓÚͼÐεÄÑéÖ¤ÂëÒѾ­³ÉΪÁËÍøÕ¾Çå¾²°ü¹ÜµÄÒ»¸öÖ÷Òª»·½Ú¡£ÑéÖ¤Âë¿ÉÒÔÓÐÓõرÜÃâ»úеÈË»ò¶ñÒâ³ÌÐò¶ÔÍøÕ¾¾ÙÐÐ×Ô¶¯»¯²Ù×÷£¬Í¬Ê±Ò²¿ÉÒÔ°ü¹ÜÓû§ÐÅÏ¢µÄÇå¾²ÐÔ¡£¶øÔÚ»ùÓÚthinkphp6µÄÍøÕ¾¿ª·¢ÖУ¬ÔõÑùʵÏÖcaptchaͼÐÎÑéÖ¤ÂëµÄ²Ù×÷ÄØ£¿±¾ÎĽ«ÎªÄúÏÈÈÝÏêϸµÄ²Ù×÷Á÷³Ì¡£

Ò»¡¢ÌìÉúCaptchaͼÐÎÑéÖ¤Âë

1¡¢Ê¹ÓÃcaptcha¿â¾ÙÐÐ×°ÖÃ

ÔÚThinkPHP6ÖоÙÐÐcaptchaͼÐÎÑéÖ¤Âë²Ù×÷£¬ÎÒÃÇÊ×ÏÈÐèҪʹÓÃcaptcha¿â¡£¿ÉÒÔͨ¹ýcomposer¾ÙÐÐ×°Öã¬ÔÚÏîÄ¿¸ùĿ¼µÄcomposer.jsonÎļþÖмÓÈ룺

"require": {
    "topthink/think-captcha": "^3.1"
}

µÇ¼ºó¸´ÖÆ

È»ºóͨ¹ýÏÂÁîÐй¤¾ßÔËÐУº

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

composer update

µÇ¼ºó¸´ÖÆ

¼´¿ÉÍê³Écaptcha¿âµÄ×°Öá£

2¡¢ÌìÉúÑéÖ¤ÂëÊý¾Ý

ÔÚÐèÒªÌìÉúÑéÖ¤Âëʱ£¬ÎÒÃÇ¿ÉÒÔ½¨ÉèÒ»¸öеĿØÖÆÆ÷À´Å²ÓÃcaptcha¿âµÄÏà¹ØÒªÁì¡£Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚ¿ØÖÆÆ÷ÖÐÒýÈëcaptcha¿â£º

use thinkcaptchaacadeCaptcha;

µÇ¼ºó¸´ÖÆ

È»ºóŲÓÃCaptcha::create()ÒªÁì¼´¿ÉÌìÉúÑéÖ¤ÂëͼƬ£¬´úÂëʾÀýÈçÏ£º

public function create()
{
    return Captcha::create();
}

µÇ¼ºó¸´ÖÆ

Õâʱ¼ä»á¼ûÏìÓ¦µÄURL£¬¾Í¿ÉÒÔ¿´µ½ÌìÉúµÄÑéÖ¤ÂëͼƬ¡£

3¡¢×Ô½ç˵ÑéÖ¤Âë²ÎÊý

ÎÒÃÇ»¹¿ÉÒÔͨ¹ý²ÎÊý×Ô½ç˵ÑéÖ¤ÂëµÄһЩÉèÖã¬ÀýÈçÑéÖ¤Â볤¶È¡¢ÑéÖ¤ÂëͼƬ¿í¶È¡¢ÑéÖ¤ÂëͼƬ¸ß¶ÈµÈµÈ¡£Ê¾ÀýÈçÏ£º

public function create()
{
    return Captcha::create('abcde', 3, 120, 36);
}

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÖУ¬’abcde’ÌåÏÖÑéÖ¤Âë¿ÉÑ¡×Ö·û¼¯£¬3ÌåÏÖÑéÖ¤Â볤¶È£¬120ºÍ36»®·ÖΪÑéÖ¤ÂëͼƬ¿í¶ÈºÍ¸ß¶È¡£ÕâÑùÉèÖÃÍê±Ïºó£¬Ôٴλá¼ûÏìÓ¦URL£¬¾Í¿ÉÒÔ¿´µ½×Ô½ç˵ÉèÖÃÌìÉúµÄÑéÖ¤ÂëͼƬ¡£

¶þ¡¢ÑéÖ¤CaptchaͼÐÎÑéÖ¤Âë

ÌìÉúÑéÖ¤Âëºó£¬ÎÒÃÇ»¹ÐèÒª¶ÔÓû§ÊäÈëµÄÑéÖ¤Âë¾ÙÐÐÑéÖ¤£¬ÒÔ°ü¹ÜÊäÈë׼ȷ¡£Í¬Ñù£¬ÎÒÃÇ¿ÉÒÔʹÓÃcaptcha¿âÌṩµÄÒªÁì¾ÙÐÐÑéÖ¤¡£ÔÚ¿ØÖÆÆ÷ÖУ¬Å²ÓÃCaptcha::check()ÒªÁì¼´¿É¶ÔÊäÈëµÄÑéÖ¤Âë¾ÙÐÐÑéÖ¤¡£Ê¾ÀýÈçÏ£º

public function check($code)
{
    if (Captcha::check($code)) {
        return 'ÑéÖ¤ÀÖ³É';
    } else {
        return 'Ñé֤ʧ°Ü';
    }
}

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬$codeÌåÏÖÓû§ÊäÈëµÄÑéÖ¤Âë¡£ÈôÊÇÑéÖ¤ÂëÊäÈë׼ȷ£¬Ôò·µ»Ø¡°ÑéÖ¤Àֳɡ±£¬²»È»·µ»Ø¡°Ñé֤ʧ°Ü¡±¡£

ÐèҪעÖصÄÊÇ£¬ÔÚ¾ÙÐÐÑéÖ¤ÂëÑé֤ʱ£¬ÐèÒªºÍÓû§ÊäÈëµÄÑéÖ¤Âë¾ÙÐоÞϸд½ÏÁ¿£¬²»È»ÑéÖ¤Ò²ÊÇ»áʧ°ÜµÄ¡£ÎÒÃÇ¿ÉÒÔÔÚÉèÖÃÎļþÖÐÉèÖþÞϸдÃô¸ÐµÄÑ¡ÏÀýÈ磺

'captcha' => [
    'reset' => true,
    'useZh' => false,
    'codeSet' => '0123456789',
    'fontSize' => 25,
    'useCurve' => false,
    'useNoise' => false,
    'imageH' => 0,
    'imageW' => 0,
    'length' => 4,
    'bg' => [243, 251, 254],
    'fontttf' => '',
    'expire' => 1800,
    'defaultCode' => '',
    'seKey' => 'thinkphp_captcha',
    'offset' => null,
    'verifyCode' => true,
    'resetCode' => true,
    'keyPrefix' => '',
    'checkSensitive' => true, // ÑéÖ¤Âë¾ÞϸдÃô¸Ð
],

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬’checkSensitive’ => trueÌåÏÖÑéÖ¤Âë¾ÞϸдÃô¸Ð¡£

ÒÔÉϾÍÊÇÔÚThinkPHP6ÖоÙÐÐcaptchaͼÐÎÑéÖ¤Âë²Ù×÷µÄÒªÁ죬ÊÊÓÃÓÚÖÖÖÖÍøÕ¾¿ª·¢³¡¾°¡£Ï£ÍûÄܹ»¶ÔÄúÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇÔõÑùÔÚThinkPHP6ÖоÙÐÐcaptchaͼÐÎÑéÖ¤Âë²Ù×÷£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ