Net_Ping::ping()

Net_Ping::ping() – pingコマンドを実行する

Synopsis

require_once 'Net/Ping.php';

string Net_Ping::ping ( string host )

Description

pingコマンドを実行します。

Parameter

  • string $host - サーバーの名前かIPアドレスを指定します。

Return value

string - pingコマンドのメッセージを返します。

Note

This function can not be called statically.

Example

Sending a ping request

<?php
require_once "Net/Ping.php";
$ping Net_Ping::factory();
if (
PEAR::isError($ping)) {
    echo 
$ping->getMessage();
} else {
    
$ping->setArgs(array('count' => 2));
    
var_dump($ping->ping('example.com'));
}
?>