我想阻止fsockopen()给我的错误。Block fsockopen()错误
(警告:的fsockopen()[function.fsockopen]:无法连接到50.31.65.135:27015(连接在/home/reverbga/public_html/query/query.php超时)第6行)
我只是想不显示,因为我使用fsockopen作为一种方式来查看服务器是否联机。
这是我的代码:
<?php
$serialized = file_get_contents('http://module.game-monitor.com/50.31.65.135:27015/data/server.php');
$players = unserialize($serialized);
$array = (array) $players;
$fp = fsockopen("50.31.65.135", 27015, $errno, $errstr, 1);
if (!$fp) {
echo "<img width='20' height='20' src='bullet_red.png' />OCRP: OFFLINE";
}
else {
echo "<img width='20' height='20' src='bullet_green.png' />OCRP: {$array['player']}/{$array['maxplayer']}";
}
?>