PHP全栈学习笔记26

作者: 魔王哪吒 | 来源:发表于2019-05-04 16:16 被阅读3次

php 验证码


image.png
<?php
/*
*@Author: 达叔小生
**/
header("Content-type:image/png");   // 发送头部信息,生成png图片文件
$str = 'qwertyuiopasdfghjklzxcvbnm1234567890';
$l = strlen($str);//得到字符串的长度
$authnum = '';
for($i=1;$i<=4;$i++){
    $num = rand(0,$i-1);//每次随机抽取一位数字
    $authnum.=$str[$num];//将通过数字得来的字符串连起来
}
srand((double)microtime()*1000000);
$im = imagecreate(50,20);
$black = imagecolorallocate($im,0,0,0);
$white = imagecolorallocate($im,255,255,255);
$gray = imagecolorallocate($im,200,200,200);
imagefill($im,68,30,$black);
imagestring($im,5,8,2, $authnum, $white);
imagepng($im);
imagedestroy($im);
?>

相关文章

  • PHP全栈学习笔记26

    php 验证码

  • PHP全栈学习笔记26

    php 验证码

  • PHP全栈学习笔记2

    php概述 什么是php,PHP语言的优势,PHP5的新特性,PHP的发展趋势,PHP的应用领域。 PHP是超文本...

  • PHP全栈学习笔记3

    trim()函数,用于去除字符串首尾空格和特殊字符返回的是去掉的空格和特殊字符后的字符串 ltrim()函数,用于...

  • PHP全栈学习笔记4

    php和JavaScript,掌握JavaScript基础,自定义函数,流程控制语句,事件,调用JavaScrip...

  • PHP全栈学习笔记5

    php与mysql数据库,PHP支持很多数据库,与mysql为牛逼组合,mysql数据库的基础知识的掌握是由必要的...

  • PHP全栈学习笔记22

    定义和用法sha1() 函数计算字符串的 SHA-1 散列。sha1() 函数使用美国 Secure Hash 算...

  • PHP全栈学习笔记24

    PHP in_array() 函数 定义和用法in_array() 函数搜索数组中是否存在指定的值。 type 参...

  • PHP全栈学习笔记25

    php验证码

  • PHP全栈学习笔记28

    数据库Mysql概述,数据库操作,数据表操作,数据类型,管理数据库 sql标准语言:数据查询语言 select数据...

网友评论

    本文标题:PHP全栈学习笔记26

    本文链接:https://www.haomeiwen.com/subject/ukzxoqtx.html