Monday, 26 August 2013

How check if succesfull cmd ping in php

How check if succesfull cmd ping in php

how can I check if a php ping returned succesfull or failed using php
exec, I have in mind something with a while loop but I'm not sure if ts
the best approach, I tried:
exec('ping www.google.com', $output)
but I would have to do a var_dump($output); to see the results, I want for
each line the ping command returns to check it
$i = 2;
while(exec('ping www.google.com', $output)) {
if($output) {
echo 'True';
} else {
echo 'False';
}
}
I know this code is WRONG but its kind of what I need, if any of you could
give me a head start on how to do it or suggestions I would really
appreciate it....THANKS!!

No comments:

Post a Comment