In this article, I will share with you How to find IP address was private or public in PHP with example. recently I was working on one payment portal and in this payment portal, I integrate many payment gateways. but in the payment integration, they only accept user public IP addresses not access private IP addresses. so, I search on google and find one solution. so, I will share it with you.
filter_var('ip_address', FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)
function ipCheck($ip_address)
{
return filter_var($ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
}
$checkPrivateIP = ipCheck('172.31.27.243');
if($checkPrivateIP == false) {
echo 'Private IP';
} else {
echo 'Public IP';
}
i hope you like this solution.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
jQuery append content inside selected element
JQuery has made easy to handle Javascrip...Laravel Passport - Create REST API with authentication
Today, in this tutorial we are share wit...How To Install and Secure MongoDB on Ubuntu
MongoDB is open-source, free and No...How to upload files in ReactJs with Example
File uploading in React.js For an...How to Build a Chrome Extension
Extensions in Google chrome and Add-ons...