$user_ip=$REMOTE_ADDR;
echo "您好,您的ip是".$user_ip;或者干脆
echo "您好,您的ip是".$REMOTE_ADDR;
;
 

解决方案 »

  1.   

    <?
    $ip = getenv("REMOTE_ADDR");
    //查看ip
    echo("你的IP地址为:$ip");
    ?> 
      

  2.   

    用这个函数
    function getIp() { 
    $ip = getenv("REMOTE_ADDR"); 
    $ip1 = getenv("HTTP_X_FORWARDED_FOR"); 
    $ip2 = getenv("HTTP_CLIENT_IP"); 
    ($ip1) ? $ip = $ip1 : null ; 
    ($ip2) ? $ip = $ip2 : null ; 
    return $ip; 
    }
      

  3.   

    在同一个局域网的应该可以得到网卡mac地址,不过主机要是linux,而且要装了super才行,好像没什么实用价值
    $tmp = tempnam('/tmp', 'mac');
    $internal_dev = 'eth0';
    $cmd = 'super arping -I '.$internal_dev.' -c 1 '.$REMOTE_ADDR.' > '.$tmp;
    exec($cmd);
    $fp = fopen($tmp,"r");
    $mesg = fread($fp,filesize($filename));
    fclose($fp);
    unlink($tmp);
    $mac = explode('[', $mesg);
    $mac = explode(']', $mac[1]);
    $nowmac = $mac[0];
    if($mac[0]==''){
    $mac = '超时没有返回!';
    }
    else
    {
    $mac = '网卡MAC地址为:'.$mac[0];
    }
      

  4.   

    谢谢大家,搞定,共享
        function getMacAddr()
        {
            $sCmd = "nbtstat -a " . getenv("REMOTE_ADDR");
            $sMac = "";
            
            $sString = shell_exec($sCmd);
            $aTemp = split("=",$sString);
            $sMac = trim($aTemp[count($aTemp)-1]);
            //echo "Mac address=".$sMac;
            return $sMac;
        }
    只适合windows环境下,UNIX环境下得用其它命令。
      

  5.   

    再次声明:
    请多看看php的中文帮助!!!!!