我试图在2个不同的输入字段中找到一个盒子,脚本ping游戏服务器并带回信息但是ping 2个服务器我想让它们放在一个盒子里而不是只是放在网站凌乱
<?php
// Include the main class file
require '../GameQ.php';
// Define your servers,
// see list.php for all supported games and identifiers.
$servers = array(
array(
'id' => 'BF4',
'type' => 'bf4',
'host' => '192.223.29.138:47200',
),
array(
'id' => 'GMOD',
'type' => 'gmod',
'host' => '31.186.251.28:27015',
)
);
// Call the class, and add your servers.
$gq = new GameQ();
$gq->addServers($servers);
// You can optionally specify some settings
$gq->setOption('timeout', 4); // Seconds
// You can optionally specify some output filters,
// these will be applied to the results obtained.
$gq->setFilter('normalise');
// Send requests, and parse the data
$results = $gq->requestData();
// Some functions to print the results
function print_results($results) {
foreach ($results as $id => $data) {
printf("<h2>%s</h2>\n", $id);
print_table($data);
}
}
function print_table($data) {
$gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type');
if (!$data['gq_online']) {
printf("<p>The server did not respond within the specified time.</p>\n");
return;
}
print("<table><thead><tr><td>Variable</td><td>Value</td></tr></thead><tbody>\n");
foreach ($data as $key => $val) {
if (is_array($val)) continue;
$cls = empty($cls) ? ' class="uneven"' : '';
if (substr($key, 0, 3) == 'gq_') {
$kcls = (in_array($key, $gqs)) ? 'always' : 'normalise';
$key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key);
}
printf("<tr%s><td>%s</td><td>%s</td></tr>\n", $cls, $key, $val);
}
print("</tbody></table>\n");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Game List</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="style.css" />
</style>
</head>
<body>
<h1>Game List</h1>
<div id="chat">
Server List. <br/>
Click <a href="list.php">here</a> for a list of supported games.
</div>
<?php
print_results($results);
?>
</body>
</html>
css
body {
background-image: url("bg.jpg");
}
table td {
color: #cccccc; // OR WHATEVER
}
h1 {
color: #00ff00;
}
#chat {
color: #00ff00;
}
答案 0 :(得分:0)
添加一些CSS以更改所需的字体颜色。文字不是黑色,只是浏览器的默认字体颜色。
table td {
color: #123456; // OR WHATEVER
}