易截截图软件、单文件、免安装、纯绿色、仅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+Ajax实现Tab效果

用Ajax实现Tab效果的
先创建
ajax.php,在其中输入如下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample 2_1</title>
<me ......

PHP数据类型的转换

PHP的数据类型的转换有两种方法可以办到:直接输入目标的数据类型和通过settype函数实现。
PHP数据转换成整数
Float型数据转换成int型
Float型转换成int型,小数点后的数将被舍弃。如果float数超贵超过了整型的取值范围,那么结果可能是0或者是整形的最小负数。
例如:
<?php
$php = 1.59;
echo (int)$php.&rdquo ......

PHP 读取地址栏 参数


1.  $_GET

http://localhost/a.php?a=ok  
   
  <?  
  echo  
$_GET['a'];   //显示"ok"  
  ?>
2.  $_SERVER['QUERY_STRING']
http://localhost/a.php?a=1&b=2&c=3  
   
  ......

PHP 中 global 变量用法

  PHP中的变量也有访问域。作用域可以使用PHP中global
  在函数内部、对象中和类中定义的局部变量在函数外部是无法被访问到的;同理,在函数外部、对象外和类外定义的变量,如果没有被传入,也是无法被访问到的。
  但是如果一个很多变量要同时被传入很多函数、对象或者类,我们也可以直接将其全局化。这样不仅可以 ......

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);
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号