收藏一個比較美觀的PHP驗證碼類_PHP教程

來源:互聯網
上載者:User
驗證碼的用途就不用多說了,之前也寫了一篇關於PHP驗證碼的文章,但是沒有封裝成類。下面就介紹一個PHP的一個驗證碼類。

codes = implode('',array_slice($codeArray,0,4));        }        public function CreateImg()        {            $_SESSION['check_pic'] = $this->codes;            $img = imagecreate(70,25);            imagecolorallocate($img,222,222,222);            $testcolor1 = imagecolorallocate($img,255,0,0);            $testcolor2 = imagecolorallocate($img,51,51,51);            $testcolor3 = imagecolorallocate($img,0,0,255);            $testcolor4 = imagecolorallocate($img,255,0,255);            for ($i = 0; $i < 4; $i++)            {                imagestring($img,rand(5,6),8 + $i * 15,rand(2,8),$this->codes[$i],rand(1,4));            }            imagegif($img);        }    }    $code = new SecurityCode();    $code->CreateImg();$code = NULL;?>

封裝成類之後,加入了建構函式,使用起來也方便些。你也可以繼續完善下這個驗證碼類,比如加入解構函式,如何更節省記憶體等等。

http://www.bkjia.com/PHPjc/752568.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/752568.htmlTechArticle驗證碼的用途就不用多說了,之前也寫了一篇關於PHP驗證碼的文章,但是沒有封裝成類。下面就介紹一個PHP的一個驗證碼類。 ?php session_s...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.