How can I get the MAC and the IP address of a connected client in PHP?

前端 未结 16 2601
长发绾君心
长发绾君心 2020-11-22 02:29

I need to know the MAC and the IP address of the connect clients, how can I do this in PHP?

16条回答
  •  深忆病人
    2020-11-22 03:12

    // Turn on output buffering  
    ob_start();  
    
    //Get the ipconfig details using system commond  
    system('ipconfig /all');  
    
    // Capture the output into a variable  
    $mycomsys=ob_get_contents();  
    
    // Clean (erase) the output buffer  
    ob_clean();  
    
    $find_mac = "Physical"; 
    //find the "Physical" & Find the position of Physical text  
    
    $pmac = strpos($mycomsys, $find_mac);  
    // Get Physical Address  
    
    $macaddress=substr($mycomsys,($pmac+36),17);  
    //Display Mac Address  
    
    echo $macaddress;  
    

    This works for me on Windows, as ipconfig /all is Windows system command.

提交回复
热议问题