header("Content-type: text/html; charset=utf-8"); //申明编码,以免页面乱码 //去掉内容中所有空格: $qian=array(" "," ","\t","\n","\r"); $hou=array("","","","",""); $data['name']=str_replace($qian,$hou,$str); gethostbyname($_ENV['COMPUTERNAME'])//获取本机IP: //全部转为大写字母 strtoupper() $_SERVER['HTTP_REFERER'];//获取上一页的URL地址 获得用户IP function getIpAddress() { // 取得当前用户的IP地址 if (getenv('HTTP_CLIENT_IP')) { $ip = getenv('HTTP_CLIENT_IP'); } elseif (getenv('HTTP_X_FORWARDED_FOR')) { $ip = getenv('HTTP_X_FORWARDED_FOR'); } elseif (getenv('REMOTE_ADDR')) { $ip = getenv('REMOTE_ADDR'); } else { $ip = $_SERVER['REMOE_ADDR']; } return $ip;} //过滤数组中为空的值 array_filter()