<?php header("Content-type:text/html;charset=‘utf8‘"); error_reporting(E_ALL); define("CAPTCHA_LEN", 16); // 随机数长度 $captchaSource = "0123456789abcdefghijklmnopqrstuvwxyz这是一个随机打印输出字符串的例子"; // 随机数字符源 $captchaResult = ""; // 随机数返回值 $captchaSentry = ""; // 随机数中间变量 for($i=0;$i<CAPTCHA_LEN;$i++){ $n = rand(0, strlen($captchaSource)); if($n >= 36){ $n = 36 + ceil(($n - 36) / 3) * 3; $captchaResult .= substr($captchaSource, $n, 3); }else{ $captchaResult .= substr($captchaSource, $n, 1); } } echo "随机打印输出字符串:".$captchaResult."<br>";
时间: 2024-10-11 20:52:08