我試圖從網絡調用請求但不工作,此代碼從網站調用命令遊戲服務器。如何在類中使用請求PHP
class SampRconAPI
{
private $command;
public function __construct()
{
$this->command = $_REQUEST["command"];
}
if($this->command == "cmdlist")
{
$aCommands = $this->packetSend('cmdlist');
unset($aCommands[0]);
foreach($aCommands as &$sCommand)
{
$sCommand = trim($sCommand);
}
return $aCommands;
}
我的錯誤:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: command
Filename: include/SampRcon.php
Line Number: 7
如果你想訪問由GET/POST傳遞比你可以用$ _REQUEST來獲取值數據。 –
是的,但我從我的網站呼叫請求它不起作用。它顯示錯誤 –
你如何創建這個類的對象? –