基于php验证码函数的使用示例 |
本文标签:php验证码 复制代码 代码如下: function _code($_code_length = 4, $_width = 75, $_height = 25){ for($i=0;$i<$_code_length;$i++){ $_nmsg .= dechex(mt_rand(0,15)); } $_SESSION["code"] = $_nmsg; $_img = imagecreatetruecolor($_width, $_height); $_white = imagecolorallocate($_img, 250, 250, 250); imagefill($_img, 0, 0, $_white); $_gray = imagecolorallocate($_img, 196, 196, 196); imagerectangle($_img, 0, 0, $_width-1, $_height-1, $_gray); for ($i=0; $i < 6; $i++) { for ($i=0; $i < 50; $i++) { for ($i=0; $i < $_code_length ; $i++) { header("Content-Type:image/png"); imagepng($_img); imagedestroy($_img); |