How do I get the IP and port of a client with PHP?
I tried the script below but it only gives me the IP address.
<?php print $_SERVER['REMOTE_ADDR']; ?>
How do I get the IP and port of a client with PHP?
I tried the script below but it only gives me the IP address.
<?php print $_SERVER['REMOTE_ADDR']; ?>
To get the port of the connected device you can use $_SERVER['REMOTE_PORT']
$ipAddress=$_SERVER['REMOTE_ADDR']; $port=$_SERVER['REMOTE_PORT'];
Port is defined in http server (Apache or other and mostly it is 80 or 443)
The php $_SERVER variables you can check at : http://www.php.net/manual/en/reserved.variables.server.php
I am sure that : REMOTE_ADDR' The IP address from which the user is viewing the current page.
But if your server is behind NAT:
:-)
Try this: