使用 php phar 进行 ping 操作
我想使用这个 脚本 进行 ping不使用 exec(); 或类似的命令。
问题是我收到这些错误:
严格标准:非静态方法 Net_Ping::factory() 不应该 在 C:\xampp\htdocs\test.php 中在线静态调用 3
严格标准:非静态方法 Net_Ping::_setSystemName() 应该 不会在 C:\xampp\php\PEAR\Net\Ping.php 第 141 行静态调用
严格标准:非静态方法 Net_Ping::_setPingPath() 应该 不会在 C:\xampp\php\PEAR\Net\Ping.php 第 143 行静态调用
严格标准:非静态方法 PEAR::isError() 不应该 在 C:\xampp\htdocs\test.php 中在线静态调用 4
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'));
}
?>
i want to use this script to do ping without using the exec();
or the commands that similar to it.
the problem is i get these errors:
Strict Standards: Non-static method Net_Ping::factory() should not be
called statically in C:\xampp\htdocs\test.php on line
3Strict Standards: Non-static method Net_Ping::_setSystemName() should
not be called statically in C:\xampp\php\PEAR\Net\Ping.php on line 141Strict Standards: Non-static method Net_Ping::_setPingPath() should
not be called statically in C:\xampp\php\PEAR\Net\Ping.php on line 143Strict Standards: Non-static method PEAR::isError() should not be
called statically in C:\xampp\htdocs\test.php on line
4
the code on 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'));
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没什么问题,PEAR 组件只是不适合 E_STRICT。您的代码没问题,但 PEAR 代码没有说该方法是静态的,因此 PHP 将发出 E_STRICT 警告。这不是您可以真正更改的内容,但您可以通过调整 error_reporting 设置来选择忽略它。
Nothing wrong, the PEAR component is just not fit for E_STRICT. The code you have is okay, but the PEAR code doesn't say the method is static, so PHP will emit an E_STRICT warning. That's not something you can really change, but you can opt to ignore it, by adjusting your error_reporting settings.
这里是我去年写的一个 ping 类需要在没有 PEAR 的系统上执行此操作。
用法示例:
Here is a ping class I wrote last year when I needed to do this on a system that didn't have PEAR.
Example usage: