Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 块fsockopen()错误_Php - Fatal编程技术网

Php 块fsockopen()错误

Php 块fsockopen()错误,php,Php,我想阻止fsockopen()给我的错误 (警告:fsockopen()[function.fsockopen]:无法连接到第6行/home/reverbga/public_html/query/query.php中的50.31.65.135:27015(连接超时) 我只是不想让它显示出来,因为我使用fsockopen作为查看服务器是否在线的一种方式 这是我的代码: <?php $serialized = file_get_contents('http://module.game-moni

我想阻止fsockopen()给我的错误

(警告:fsockopen()[function.fsockopen]:无法连接到第6行/home/reverbga/public_html/query/query.php中的50.31.65.135:27015(连接超时)

我只是不想让它显示出来,因为我使用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']}";
}

?>
您可以尝试:


您应该在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']}";
}  

?>

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

?>