所以我将这段代码放在一起,为我的服务器ping了在线播放器计数/最大播放器插槽。我想我已经完成了所有事情,但是这个错误发生了......关于如何修复它的任何建议? 这是错误: 解析错误:语法错误,意外'<'在/home/u7335206/public_html/mc-vr.com/pc.php第21行
这是我的代码:
<?php
require "MinecraftQuery.class.php";
// Variables for each of your servers:
$server_info = array();
try
{
// Getting Server Info:
$query = new MinecraftQuery();
$query->Connect("192.99.14.177", 25573);
$server_info = $query->GetInfo();
}
catch(MinecraftQueryException $e)
{
// Getting the information failed.
}
try
{
<?php if ($server_info) { ?>
<p><span style='font-family: Arial; font-weight: normal; font-style: normal; text-decoration: none;'><font color='#FFFFFF'><?= $server_info["numplayers"] ?>/<?= $server_info["maxplayers"] ?></font></span></p>
<?php } else { ?>
<p><span style='font-family: Arial; font-weight: normal; font-style: normal; text-decoration: none;'><font color='#FFFFFF'>0/120</span></font></p>
<?php } ?>
答案 0 :(得分:1)
更改
try
{
<?php if ($server_info) { ?>
到
try
{
if ($server_info) { ?>
您还缺少try
的结束括号。但是,由于您没有执行catch()
,只需删除try
<?php
require "MinecraftQuery.class.php";
// Variables for each of your servers:
$server_info = array();
try
{
// Getting Server Info:
$query = new MinecraftQuery();
$query->Connect("192.99.14.177", 25573);
$server_info = $query->GetInfo();
}
catch(MinecraftQueryException $e)
{
// Getting the information failed.
}
if ($server_info) { ?>
<p><span style='font-family: Arial; font-weight: normal; font-style: normal; text-decoration: none;'><font color='#FFFFFF'><?= $server_info["numplayers"] ?>/<?= $server_info["maxplayers"] ?></font></span></p>
<?php } else { ?>
<p><span style='font-family: Arial; font-weight: normal; font-style: normal; text-decoration: none;'><font color='#FFFFFF'>0/120</span></font></p>
<?php } ?>