标签:style blog class code c tar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 |
<?php session_start(); $arr = array ( ‘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‘ , ‘0‘ , ‘1‘ , ‘2‘ , ‘3‘ , ‘4‘ , ‘5‘ , ‘6‘ , ‘7‘ , ‘8‘ , ‘9‘ ); $rand = "" ; for ( $i =1; $i <=4; $i ++){ <span style= "background-color: rgb(192, 192, 192);" > //随机产生4个由不同字母与数字组合成的验证码</span> $rand
.= $arr [rand(0, count ( $arr )-1)]; } $_SESSION [ ‘check_pic‘ ] = $rand ; <span style= "background-color: rgb(192, 192, 192);" > //生成图片</span> $im = <span style= "color: rgb(255, 0, 0);" >imagecreatetruecolor</span>(100,30); <span style= "background-color: rgb(192, 192, 192);" > //生成颜色,当第一次调用生成颜色的方法,是生成背景颜色</span> $bg = <span style= "color: rgb(255, 0, 0);" >imagecolorallocate</span>( $im ,0,0,0); <span style= "background-color: rgb(192, 192, 192);" > //第二次调用这个方法,是可以生成图片上面的文字或其他样式的颜色 </span> $te
=<span style= "color: rgb(255, 0, 0);" > imagecolorallocate</span>( $im ,255,255,255); <span style= "background-color: rgb(192, 192, 192);" > //在图片上面生成文字</span> <span style= "color: rgb(255, 0, 0);" >imagestring</span>( $im ,rand(1,5),rand(3,70),rand(3,15), $rand , $te ); <span style= "background-color: rgb(192, 192, 192);" > //要把php当成图片输出,必须给文件一个头申明</span> <span style= "color: rgb(255, 0, 0);" >ob_clean()</span>; <span style= "color: rgb(255, 0, 0);" >header</span>( "Content-type:image/jpeg" ); <span style= "background-color: rgb(192, 192, 192);" > //最终生成图片</span> <span style= "color: rgb(255, 0, 0);" >imagejpeg</span>( $im ); ?> |
1 |
<span style= "background-color: rgb(255, 102, 0);" >imagecreatetruecolor(宽,高); 图片宽高</span> |
1 |
<span style= "background-color: rgb(255, 102, 0);" >imagecolorallocate(图片,红,绿,蓝) <span style= "line-height: 1.5;" >调用(三原色)生成颜色的方法,是生成背景颜色</span></span> |
1 |
<span style= "background-color: rgb(255, 102, 0);" >imagestring<span style= "line-height: 1.5;" >(图片,字体大小,字所在的x轴,</span><span style= "line-height: 1.5;" >字所在的y轴,要显示的验证码,字体颜色</span><span style= "line-height: 1.5;" >)<br></span></span> |
1 |
<span style= "background-color: rgb(255, 102, 0);" >header 要把php当成图片输出,必须给文件一个头申明</span> |
1 |
<span style= "background-color: rgb(255, 102, 0);" >imagejpeg(图片) 生成图片</span> |
1 |
|
1 |
<br><br><br> |
标签:style blog class code c tar
原文地址:http://www.cnblogs.com/5huihui/p/3726649.html