php 数学运算验证码实现代码
2015-01-24信息快讯网
php 数学运算验证码实现代码
<?php
//-------------------------------------
// 文件说明:数学运算验证码
// 文件作者:Jesse Lee
// 最后更新:2008-09-07
//-------------------------------------
session_start();
$sessionvar = 'vdcode'; //Session变量名称
$width = 150; //图像宽度
$height = 20; //图像高度
$operator = '+-*'; //运算符
$code = array();
$code[] = mt_rand(1,9);
$code[] = $operator{mt_rand(0,2)};
$code[] = mt_rand(1,9);
$code[] = $operator{mt_rand(0,2)};
$code[] = mt_rand(1,9);
$codestr = implode('',$code);
eval("\$result = ".implode('',$code).";");
$code[] = '=';
$_SESSION[$sessionvar] = $result;
$img = ImageCreate($width,$height);
ImageColorAllocate($img, mt_rand(230,250), mt_rand(230,250), mt_rand(230,250));
$color = ImageColorAllocate($img, 0, 0, 0);
$offset = 0;
foreach ($code as $char) {
$offset += 20;
$txtcolor = ImageColorAllocate($img, mt_rand(0,255), mt_rand(0,150), mt_rand(0,255));
ImageChar($img, mt_rand(3,5), $offset, mt_rand(1,5), $char, $txtcolor);
}
for ($i=0; $i<100; $i++) {
$pxcolor = ImageColorAllocate($img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));
ImageSetPixel($img, mt_rand(0,$width), mt_rand(0,$height), $pxcolor);
}
header('Content-type: image/png');
ImagePng($img);
?>
PHP中使用CURL伪造来路抓取页面或文件
php中记录用户访问过的产品,在cookie记录产品id,id取得产品信息
PHP的substr_replace将指定两位置之间的字符替换为*号
php join函数应用
php中处理mysql_fetch_assoc返回来的数组 不用foreach----echo
PHP下对字符串的递增运算代码
PHP对字符串的递增运算分析
PHP 作用域解析运算符(::)
php下使用strpos需要注意 === 运算符
php && 逻辑与运算符使用说明
php侧拉菜单 漂亮,可以向右或者向左展开,支持FF,IE
用mysql触发器自动更新memcache的实现代码
基于OpenCV的PHP图像人脸识别技术
PHP 身份验证方面的函数
PHP iconv 函数转gb2312的bug解决方法
Ha0k 0.3 PHP 网页木马修改版
PHP获取163、gmail、126等邮箱联系人地址【已测试2009.10.10】
php合并数组array_merge函数运算符加号与的区别
PHP学习 运算符与运算符优先级