北京园林的色彩大多为金黄或大红,色彩明丽。有时,在万绿丛中见一道飞檐,黄绿相间,相映成趣。大多数宫殿者哺着琉璃瓦,大红色的棱、柱过于庄重,而幽雅倒显得欠缺。也有例外的,潭拓寺的大殿都是由灰色方砖铺地,墙壁也都是灰暗的,同周围的景色浑然一体。 "苔痕上阶绿,草色入帘青 ",古朴淡雅,别具风采。
本文实例讲述了PHP生成图片验证码功能。分享给大家供大家参考,具体如下:
只是简单的用随机函数实现了图片的生成,没有对验证的整个流程做介绍。
代码如下:
<?php /** * Created by JetBrains PhpStorm. * User: lee * To change this template use File | Settings | File Templates. */ header("content-type:image/png"); $validateLength=4; $strToDraw=""; $chars=[ "0","1","2","3","4", "5","6","7","8","9", "a","b","c","d","e","f","g", "h","i","j","k","l","m","n", "o","p","q","r","s","t", "u","v","w","x","y","z", "A","B","C","D","E","F","G", "H","I","J","K","L","M","N", "O","P","Q","R","S","T", "U","V","W","X","Y","Z" ]; $imgW=80; $imgH=25; $imgRes=imagecreate($imgW,$imgH); $imgColor=imagecolorallocate($imgRes,255,255,100); $color=imagecolorallocate($imgRes,0,0,0); for($i=0;$i<$validateLength;$i++){ $rand=rand(1,58); $strToDraw=$strToDraw." ".$chars[$rand]; } imagestring($imgRes,5,0,5,$strToDraw,$color); for($i=0;$i<100;$i++){ imagesetpixel($imgRes,rand(0,$imgW),rand(0,$imgH),$color); } imagepng($imgRes); imagedestroy($imgRes);
运行效果如下:
PS:这里再为大家推荐几款比较实用的图片处理工具供大家参考使用:
在线图片转换BASE64工具:
http://tools.haodaima.com/transcoding/img2base64
ICO图标在线生成工具:
http://tools.haodaima.com/aideddesign/ico_img
在线Email邮箱图标制作工具:
http://tools.haodaima.com/email/emaillogo
在线图片格式转换(jpg/bmp/gif/png)工具:
http://tools.haodaima.com/aideddesign/picext
希望本文所述对大家PHP程序设计有所帮助。
到此这篇关于PHP生成图片验证码功能示例就介绍到这了。人生就像迷宫,我们用上半生寻找入口,用下半生寻找出口。更多相关PHP生成图片验证码功能示例内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!