header( 'Content-type: text/html;charset=utf-8' );//设置页面编码
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"' ); //个人隐私保护
iconv("GB2312", "UTF-8",$str); //中文转英文
header("Location: {$url}");//重定向
set_time_limit( $seconds);//0不限制
date_default_timezone_set('Asia/Chongqing');//设定用于一个脚本中所有日期时间函数的默认时区;//'Asia/Shanghai' 亚洲/上海Asia/Chongqing'为“亚洲/重庆”PRC为“中华人民共和国”
匹配只有中文
preg_match("/^[\x{4e00}-\x{9fa5}]+$/u",$name)
preg_match('/([\x80-\xFE][\x40-\x7E\x80-\xFE])+/', $name)
preg_match("/[".chr(0xa1)."-".chr(0xff)."]/", $name)
/**
* [date 转换成 unix时间戳]
* @param string $date [description]
* @return [type] [description]
*/
if ( ! function_exists('date_to_unixtime'))
{
function date_to_unixtime($date = "2038-01-19 11:14:07") {
$datetime = new DateTime($date);
return $datetime->format('U');//输出2147483647
}
}
/**
* [unix时间戳 转换成 date]
* @param string $unixtime [description]
* @param integer $timezone [description]
* @return [type] [description]
*/
if ( ! function_exists('unixtime_to_date'))
{
function unixtime_to_date($unixtime = '2147483647', $format ="Y-m-d" ,$timezone = 8) {
$time = $unixtime + $timezone * 3600;
$datetime = new DateTime("@$time"); //DateTime类的bug,加入@可以将Unix时间戳作为参数传入DateTime构造函数
return $datetime->format($format);//输出2038-01-19 11:14:07
}
}