使用php-phar进行ping

使用php-phar进行ping,php,ping,Php,Ping,我想使用它来执行ping,而不使用exec()或与之类似的命令 问题是我遇到了以下错误: 严格标准:不应使用非静态方法Net\u Ping::factory() 在C:\xampp\htdocs\test.php中在线静态调用 三, 严格标准:非静态方法Net\u Ping::\u setSystemName()应 不能在C:\xampp\php\PEAR\Net\Ping.php的第141行静态调用 严格标准:非静态方法Net\u Ping::\u setPingPath()应该 不能在C:\

我想使用它来执行ping,而不使用
exec()
或与之类似的命令

问题是我遇到了以下错误:

严格标准:不应使用非静态方法Net\u Ping::factory() 在C:\xampp\htdocs\test.php中在线静态调用 三,

严格标准:非静态方法Net\u Ping::\u setSystemName()应 不能在C:\xampp\php\PEAR\Net\Ping.php的第141行静态调用

严格标准:非静态方法Net\u Ping::\u setPingPath()应该 不能在C:\xampp\php\PEAR\Net\Ping.php的第143行静态调用

严格的标准:不应使用非静态方法PEAR::isError() 在C:\xampp\htdocs\test.php中在线静态调用 四,

test.php上的代码

<?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'));
}
?>

是我去年编写的一个ping类,当时我需要在没有PEAR的系统上执行此操作

用法示例:

$ping = new ping();
if (!$ping->setHost('google.com')) exit('Could not set host: '.$this->getLastErrorStr());
var_dump($ping->send());
这是我去年写的一个ping类,当时我需要在一个没有PEAR的系统上执行此操作

用法示例:

$ping = new ping();
if (!$ping->setHost('google.com')) exit('Could not set host: '.$this->getLastErrorStr());
var_dump($ping->send());

没什么问题,PEAR组件不适合E_STRICT。您拥有的代码还可以,但是PEAR代码没有说明该方法是静态的,因此PHP将发出E_严格警告。这不是你真正可以改变的,但是你可以通过调整你的错误报告设置来选择忽略它

<?php
// before PEAR stuff.
$errLevel = error_reporting( E_ALL );

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

// restore the original error level.
error_reporting( $errLevel );
var_dump( $result );

没什么问题,PEAR组件不适合E_STRICT。您拥有的代码还可以,但是PEAR代码没有说明该方法是静态的,因此PHP将发出E_严格警告。这不是你真正可以改变的,但是你可以通过调整你的错误报告设置来选择忽略它

<?php
// before PEAR stuff.
$errLevel = error_reporting( E_ALL );

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

// restore the original error level.
error_reporting( $errLevel );
var_dump( $result );

你的代码在哪里,看起来错误消息清楚地解释了什么是错误的。代码在这里,我没有找到这个文件C:\xampp\php\PEAR\Net\Ping.php我从PEAR.php下载了这个文件。我们需要
C:\xampp\htdocs\test.php
你的代码在哪里,看起来错误消息清楚地解释了问题所在。代码在这里,我没有看到这个文件C:\xampp\php\PEAR\Net\Ping.php我从PEAR.phpw下载了这个文件。我们需要
C:\xampp\htdocs\test.php
中的代码,它是否使用exec()或类似的代码,如果没有,是什么?不,它不使用exec或类似的文件,它使用的是php吗或者类似的,如果不是什么是的?不,它不是exec或类似的,它使用PHP