Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

ping with PHP

codecraigcodecraig Member Posts: 163
anyone know how to ping with PHP, and return the results??

shown below are the things I have tried, yet haven't worked!

[code]
<?php
$itemnum = 1;
exec("ping -c 1 eqlounge.com",$data_array,$iValue);
foreach($item in $data_array)
{
echo "Item #" . $itemnum . " - " . $item;
$itemnum++;
}
?>
[/code]

[code]
<?

$comm='ping -c 1 yahoo.com';

$res=shell_exec($comm);

echo $res;

?>
[/code]

thx
craig
[email protected]

Comments

  • fnoyanfnoyan Member Posts: 103
    : anyone know how to ping with PHP, and return the results??
    :
    : shown below are the things I have tried, yet haven't worked!
    :
    : [code]
    : <?php
    : $itemnum = 1;
    : exec("ping -c 1 eqlounge.com",$data_array,$iValue);
    : foreach($item in $data_array)
    : {
    : echo "Item #" . $itemnum . " - " . $item;
    : $itemnum++;
    : }
    : ?>
    : [/code]
    :
    : [code]
    : <?
    :
    : $comm='ping -c 1 yahoo.com';
    :
    : $res=shell_exec($comm);
    :
    : echo $res;
    :
    : ?>
    : [/code]
    :
    : thx
    : craig
    : [email protected]
    :

    Your second code works fine! Where is the problem! If you want a better output use echo "[code]
    $res
    [/code]";

Sign In or Register to comment.