您好,登錄后才能下訂單哦!
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2017\10\10 0010 * Time: 19:44 */ //生成隨機(jī)驗(yàn)證碼 $strNumber = join('',range(0,9)); $strChar = join('',range('a','z')); $str = $strNumber.$strChar.strtoupper($strChar); $str = substr(str_shuffle($str),'0',4); header("Content-type: p_w_picpath/png"); //創(chuàng)建畫布 $width = 100; $height = 50; $p_w_picpath = p_w_picpathcreate($width,$height); //創(chuàng)建顏色 $bgcolor = p_w_picpathcolorallocate($p_w_picpath,rand(0,20),rand(0,20),rand(0,20)); //備用顏色(干擾線) $colorone = p_w_picpathcolorallocate($p_w_picpath,rand(100,155),rand(200,155),rand(100,155));; //干擾線 for($j=0; $j<10; $j++){ p_w_picpathline($p_w_picpath, rand(0,$width), rand(0,$height-20), rand(0,$width), rand(0,$height), $colorone); } //循環(huán)添加字符到畫布 每個字符的坐標(biāo)為(總寬度 / 驗(yàn)證碼的個數(shù)) for($i=0; $i<4; $i++){ //備用顏色(文字) $fontcolor= p_w_picpathcolorallocate($p_w_picpath,rand(0,255),rand(100,200),rand(180,255)); $x = (($width / 4) * $i) + $width / 10; $y = rand(10,$height-20); p_w_picpathchar($p_w_picpath, 5, $x, $y,$str[$i], $fontcolor); } p_w_picpathpng($p_w_picpath); p_w_picpathdestroy($p_w_picpath);
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。