PHP 7 Script to Get Remote IP Address and MAC Address of Connected Client in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

 

Welcome folks today in this blog post we will be getting remote ip address and mac address of connected client in browser using php 7.All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.php  file and copy paste the following code

 

 

index.php

 

 

 

Getting IP Address

 

 

<?php
  
// PHP program to get IP address of client
$IP = $_SERVER['REMOTE_ADDR'];
  
// $IP stores the ip address of client
echo "Client's IP address is: $IP";
  
// Print the ip address of client
?>

 

See also  PHP 7 Script to Add Two Numbers Using + Operator in Browser Full Project For Beginners

 

 

Getting MAC Address

 

 

index.php

 

 

<?php

// PHP code to get the MAC address of Client
$MAC = exec('getmac');

// Storing 'getmac' value in $MAC
$MAC = strtok($MAC, ' ');

// Updating $MAC value using strtok function,
// strtok is used to split the string into tokens
// split character of strtok is defined as a space
// because getmac returns transport name after
// MAC address
echo "MAC address of client is: $MAC";
?>

Leave a Reply