我正在使用this script here並且它並不總是想連接到我設置的服務器。如果沒有,則會顯示錯誤"Failed to receive status"
。我想知道如何測試以查看是否發生這種情況並將其放入if語句中?測試連接是否爲錯誤
例如:
if (isError) return false;
這裏是一個檢查錯誤或不執行腳本的一部分:
if(!$Data)
{
throw new MinecraftQueryException("Failed to receive status.");
}
我在調用對象時能做到這一點嗎?例如,嘗試{echo $ cbMain-> GetInfo()['Players']} catch(error){}它是否在對象內部? – devs
是的,在試塊中做所有正常的操作。 –
@DEVS查看更新。另請參閱README.md https://github.com/xPaw/PHP-Minecraft-Query/blob/master/README.md –