【发布时间】:2015-09-02 00:30:08
【问题描述】:
我正在使用试图学习的类和函数,并且正在执行 fsockopen 以检查服务器是否在线。当我直接从页面执行此操作(不调用该函数)时,一切都很好。我试图仅为特定函数关闭错误报告。 编辑:我也尝试将 error_reporting 直接添加到函数中,但也没有用。
class server
{
public function __construct() {
global $servhost;
global $gameport;
global $loginport;
$this->fp = fsockopen($servhost, $gameport, $errno, $errstr, 5);
$this->er = error_reporting(0);
}
function servstatus()
{
// tried this echo $this->er;
// tried this $this->er;
// tried this error_reporting(0);
if ($this->fp) {
echo "Server Online";
fclose($this->fp);
} else {
echo "Server Offline";
fclose($this->fp);
}
}
}
【问题讨论】:
-
投反对票的人能否解释一下这篇文章为什么没有显示出研究成果、不清楚或没有用处?
标签: php