1,正则匹配中文字符:/^[\x{4e00}-\x{9fa5}]+$/u
eg: preg_match("/^[\x{4e00}-\x{9fa5}]+$/u", $string);
2,PHP获取用户访问真实IP地址
function getIP ()
{
global $_SERVER;
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
} else if (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} else if (getenv('REMOTE_ADDR')) {
$ip = getenv('REMOTE_ADDR');
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
网友评论