易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP生成随机字符串的方法

Code:
<?php
function genRandomString($len)
{
$chars = 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", "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"
);
$charsLen = count($chars) - 1;
shuffle($chars);    // 将数组打乱
$output = "";
for ($i=0; $i<$len; $i++)
{
$output .= $chars[mt_rand(0, $charsLen)];
}
return $output;
}
$str = genRandomString(4); //输入要输入的随机数的个数;
$str .= "<br />";
$str .= genRandomString(4);
$str .= "<br />";
$str .= genRandomString(4);
echo $str;
?>


相关文档:

PHP htmlspecialchars() 函数


定义和用法
htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体。
预定义的字符是:
& (和号) 成为 &amp;
" (双引号) 成为 &quot;
' (单引号) 成为 &#039;
< (小于) 成为 &lt;
> (大于) 成为 &gt;
语法
htmlspecialchars(string,quotestyle,character-se ......

PHP 中获取文件名及路径


  为了脚本程序的兼容性,很多时候脚本的名称都不是固定的。所以我们需要通过动态获取当前脚本的路径、文件名来完成某些功能。
  PHP 中,我们可以使用常量 __FILE__ 来获取当前被执行脚本的完整路径。
  注意:当包含此变量的脚本被其他脚本include或者require的时候, __FILE__ 将仍然返回此脚本的地址,而不是 ......

PHP验证码生成脚本(5位数字png格式)


<?php
header("Content-Type:image/png");
srand((double)microtime()*1000000);
$img_height=20;
$img_width=60;
$im=@imagecreate($img_width,$img_height) or die("不能初始化GD文件流");
$background_color=imagecolorallocate($im,255,255,255);
$text_color=imagecolorallocate($im,233,14,91);
......

[PHP]PDO的使用

1. 安装php5.1以上的版本,有支持pdo!为了使你的环境能提供对pdo的支持!在php.ini文件加入以下:
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_mssql.dll(支持mssql数据库)
2. 以下为PH中PDO的具体使用
 <?php
$dsn = 'mysql:dbname=MyDbName;host=localhost';
$user = 'root';
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号