zoukankan      html  css  js  c++  java
  • php验证码

    <?php
    header("Content-Control:no-cache");//修改响应消息头
    header("Content-type:image/png");
    /*
     * 使用php想客户端输出验证码图片
     * 提示:下面的新函数仅做了解
     * */
        $w = 100; //图片宽
        $h = 30; //图片高
        $img=imagecreatetruecolor($w, $h);//在服务器的内存中创建一副图片
        $c=imagecolorallocate($img,rand(150, 230),rand(150, 230),rand(150, 230));//创建一个颜色
        imagefilledrectangle($img, 0, 0, $w, $h, $c);//在图片上绘制一个矩形
        ///绘制五个随机的文字
        $src="ABCEFGASKFJKASBJKF3456789";
        for($i=0;$i<5;$i++){
            $s=$src[rand(0, strlen($src)-1)];//获取员工个随机字符
            $c=imagecolorallocate($img,rand(50, 150),rand(50, 150),rand(50, 150));
            imagettftext($img,rand(10, 30),rand(-45, 45), 20*$i+5,rand(10, 30),$c,'arial.ttf',$s);//在图片上绘制一个文字
        }
        imagepng($img);//以png格式讲服务器上的图片输出给库户端
        imagedestroy($img);//在服务器内存里销毁该图片
       
        require '';
    ?>

  • 相关阅读:
    2008年总结
    感触
    24105
    事情总喜欢蜂拥而至
    最后的稻草
    什么叫服务
    sigh,终于submit了
    在工作和生活的狭缝中生存着
    不应该,不应该
    ren 人 认 忍 韧 仁
  • 原文地址:https://www.cnblogs.com/longly/p/6030977.html
Copyright © 2011-2022 走看看