$obj= NewClass_guest_info;
$obj -Getlang(); //get the language of your visitors: Simplified Chinese, Traditional Chinese,中文版.
$obj -Getbrowser(); //Get the Guest browser:MSIE,Firefox,Chrome,Safari,Opera, Other.
$obj -Getos(); //Get guest operating system:Windows,MAC,Linux,Unix,BSD, Other.
$obj -GetIP(); //Get VisitorsIPaddress.
$obj -Getadd(); //get a visitor's location, useBaiduhides the interface.
$obj -Getisp(); //Get VisitorsISP, usingBaiduhides the interface.
classClass_guest_info
{
functionGetlang()
{
$Lang= substr($_server[' Http_accept_language '], 0, 4);
//Usesubstr ()intercepts a string from0bit start, intercept4of characters
if(Preg_match('/zh-c/i ', $Lang)) {
//preg_match ()Regular expression matching function
$Lang= 'Simplified Chinese';
}ElseIf(Preg_match('/zh/i ', $Lang)) {
$Lang= 'Traditional Chinese';
}Else{
$Lang= ' 中文版 ';
}
return$Lang;
}
functionGetbrowser()
{
$Browser= $_server[' Http_user_agent '];
off(Preg_match('/msie/i ', $Browser)) {
$Browser= ' MSIE ';
}ElseIf(Preg_match('/firefox/i ', $Browser)) {
$Browser= ' Firefox ';
}ElseIf(Preg_match('/chrome/i ', $Browser)) {
$Browser= ' Chrome ';
}ElseIf(Preg_match('/safari/i ', $Browser)) {
$Browser= ' Safari ';
}ElseIf(Preg_match('/opera/i ', $Browser)) {
$Browser= ' Opera ';
}Else{
$Browser= ' Other ';
}
return$Browser;
}
functionGetos()
{
$OS= $_server[' Http_user_agent '];
if(Preg_match('/win/i ', $OS)) {
$OS= ' Windows ';
}ElseIf(Preg_match('/mac/i ', $OS)) {
$OS= ' MAC ';
}ElseIf(Preg_match('/linux/i ', $OS)) {
$OS= ' Linux ';
}ElseIf(Preg_match('/unix/i ', $OS)) {
$OS= ' Unix ';
}ElseIf(Preg_match('/bsd/i ', $OS)) {
$OS= ' BSD ';
}Else{
$OS= ' Other ';
}
return$OS;
}
functionGetIP()
{
if(!Emptyempty($_server[' Http_client_ip '])) {
//If the variable is a non-null or nonzero value, theempty ()returnFALSE.
$IP= Explode(',', $_server[' Http_client_ip ']);
}ElseIf(!Emptyempty($_server[' Http_x_forwarded_for '])) {
$IP= Explode(',', $_server[' Http_x_forwarded_for ']);
}ElseIf(!Emptyempty($_server[' REMOTE_ADDR '])) {
$IP= Explode(',', $_server[' REMOTE_ADDR ']);
}Else{
$IP[0] = ' None ';
}
return$IP[0];
}
Private FunctionGetaddisp()
{
$IP= $this -GetIP();
$ADDISP= mb_convert_encoding(file_get_contents(' http://open.baidu.com/ipsearch/stn=ipjson&wd= '. $IP), ' UTF-8 ', ' GBK ');
//mb_convert_encoding ()converts the character encoding.
if(Preg_match('/noresult/i ', $ADDISP)) {
$ADDISP= ' None ';
}Else{
$Sta= Stripos($ADDISP, $IP)+ strlen($IP)+ strlen('from');
$Len= Stripos($ADDISP, '"}')- $Sta;
$ADDISP= substr($ADDISP, $Sta, $Len);
}
$ADDISP= Explode(' ', $ADDISP);
return$ADDISP;
}
functionGetadd()
{
$ADD= $this -Getaddisp();
return$ADD[0];
}
functionGetisp()
{
$ISP= $this -Getaddisp();
if($ISP[0] != ' None '&&isset($ISP[1])) {
$ISP= $ISP[1];
}Else{
$ISP= ' None ';
}
return$ISP;
}
}
The above describes the PHP language, browser, operating system, IP, geographical location, ISP, including the content, I hope the PHP tutorial interested in a friend helpful.