Skip to content

Instantly share code, notes, and snippets.

@MajideND
Last active February 21, 2022 06:50
Show Gist options
  • Save MajideND/f36251541b9b0d7ab5990f4ab2628934 to your computer and use it in GitHub Desktop.
Save MajideND/f36251541b9b0d7ab5990f4ab2628934 to your computer and use it in GitHub Desktop.
Safest code to get user real IP Address in PHP
<?php
function _getUserRealIP() {
$ipaddress = '';
if(isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment