I am Integrating payumoney payment gateway in client website. Sometimes success URL is not been called due to internet connection issue. So I want to check internet connection strength and depend on it proceed to payment. I Can't get output Please help Me...
Asked
Active
Viewed 405 times
1 Answers
1
you can use below function and send an IP ( for example google DNS ips : 8.8.8.8 or 4.2.2.4 ... ) to check internet connection from your server
protected function ping($ip)
{
$output = shell_exec('ping -c1 '. $ip);
if (strpos($output, '1 received, 0% packet loss')) {
return 1;
} else {
return 0;
}
}
it will return 1 ( if you have internet connection ) or 0 ( if you dont )

Mhmd
- 406
- 5
- 12
-
Thanks for an answer But I want to check signal strength not internet connected or not – Raghunath Raut Jun 30 '18 at 04:53
-
hmm. you can change the shell_exec function i think you need to check time of response for example ping result : (64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=114 ms) and 'time' will show strength of connection . am i wrong ? – Mhmd Jun 30 '18 at 05:01