2

How to get client ip address and port in php ? i need to implement this to with when visitors come with IP and PORT ?

$linebyLine = date('Y-m-d H:i:s') . " - $_SERVER[HTTP_CF_CONNECTING_IP]";
file_put_contents('visitors.log', $linebyLine . PHP_EOL, FILE_APPEND);
Vision Coderz
  • 8,257
  • 5
  • 41
  • 57

2 Answers2

1

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.

Arun Vitto
  • 163
  • 10
1

you can use$_SERVER['REMOTE_ADDR'] to get client IP address and $_SERVER['REMOTE_PORT'] to get port

Abhin K
  • 128
  • 2
  • 11