PHP实例:用SESSION方法实现验证码
index.php(实现输入验证码页面)代码如下: Code代码如下: <html>
<head>
<title>check code</title>
</head>
<body>
<form name=check method=post action=check.php>
<input type=hidden name=init value=1>
验证码:<input type=text name=code maxlength=4 style="width=50px;">
<!--得到验证码图片-->
<img src=image.php>
<p>
<input type=submit value="提交">
</form>
</body>
</html> image.php(验证码生成页面)代码如下: Code代码如下: <?php
session_start();
srand((double)microtime()*1000000);
$authnum=rand(1000,9999);
session_register("authnum");
header("content-type:image/png");
function creat_image( $width, $height, $authnum)
{
srand((double)microtime()*1000000);
$im = imagecreate( $width, $height);
$black = ImageColorAllocate( $im, 0,0,0);
$white = ImageColorAllocate( $im, 255,255,255);
$gray = ImageColorAllocate( $im, 200,200,200);
imagefill( $im,0,0, $gray);
//将四位整数验证码绘入图片
imag
相关文档:
array array_diff
( array array1, array array2 [, array
...] )
array_diff()
返回一个数组,该数组包括了所有在 array1
中但是不在任何其它参数数组中的值。注意键名保留不变。
猛的一看这个方法,还以为是将两个数组中不同的返回来呢,事实上不是,返回的是在array1中的,但是不在其他数组中的。 ......
64位动态php扩展库的编译
工作上需要,这个问题折腾了一阵子。不过当编译成功之后,心里还是相当的兴奋,感受到了一种成就感。也是工作中的一种乐趣。
现在将整个过程写下来,以备后续之需。
a.shared object
(1) download and install the apache
从网络中下载apache-2.0.48.tar.gz
存至/home/tmp
cd /home/ ......
#找到:
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gz ......
对比起 Cookie,Session 是存储在服务器端的会话,相对安全,并且不像 Cookie 那样有存储长度限制,本文简单介绍 Session 的使用。
由于 Session 是以文本文件形式存储在服务器端的,所以不怕客户端修改 Session 内容。实际上在服务器端的 Session 文件,PHP 自动修改 Session 文件的权限,只保留了系统读和写权限,而 ......