PHP常用函数使用实例(1)

文章摘要:这是一些使用频率比较高的函数,有的来自别人的程序...... 1.产生随机字符串函数 function random($length) { $hash = ''; $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; $max = strlen($chars) - 1; mt_srand((double)microtime() * 1000000); for($i = 0; $i <
һϢϵͳܱǸύлʵкϵͳĹؼʻIPܵ˷ƣβЧϵͳѼ¼IPύݡע⣬ҪύκΥҹ涨ݣصϢΪgooglesyndication
p = explode('/',$dir);

$cur_dir = '';

for($i=0;$i<count($temp);$i++)

{

$cur_dir .= $temp[$i].'/';

if (!is_dir($cur_dir))

{

@mkdir($cur_dir,0777);

}

}

}

}

5.判断邮箱地址

function checkEmail($inAddress)

{

return (ereg("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+",$inAddress));

}

6.跳转

function gotourl($message='',$url='',$title='')

{

$html ="<html><head>";

if(!empty($url))

$html .="<meta http-equiv='refresh' content=\"3;url='".$url."'\">";(欢迎访问“电脑街!”)

$html .="<link href='../templates/style.css' type=text/css rel=stylesheet>";

$html .="</head><body><br><br><br><br>";

$html .="<table cellspacing='0' cellpadding='0' border='1' width='450' align='center'>";

$html .="<tr><td bgcolor='#ffffff'>";

$html .="<table border='1' cellspacing='1' cellpadding='4' width='100%'>";

$html .="<tr class='m_title'>";

$html .="<td>".$title."</td></tr>";

$html .="<tr class='line_1'><td align='center' height='60'>";

$html .="<br>".$message."<br><br>";

if (!empty($url))

$html .="系统将在3秒后返回<br>如果您的浏览器不能自动返回,请点击[<a href=".$url." target=_self>这里</a>]进入";

else

$html .="[<a href='#' onclick='history.go(-1)'>返回</a>]";

$html .="</td></tr></table></td></tr></table>";

$html .