2016-02-27 147 views
2

我想通过网络发送自定义文本到我的游戏服务器throught这个剧本,但我不知道如何定义里面输入器Rcon,发送命令给服务器

任何提示或建议或固定的文本?

脚本是:

<?php 
function send_command($ip,$port,$rcon,$command) { 
    $fp = @fsockopen("udp://".$ip, $port, $errno, $errstr); 
    if ($fp){ 
     $request = chr(1).chr(0).chr(242).chr(strlen($rcon)).$rcon.pack("S",strlen($command)).$command; 
     fwrite($fp, $request); 
    } 
} 

$name = "Owner"; 
echo "<input type='text' name='$msg'"; 

if (isset($_REQUEST['send'])) { 
    send_command("192.168.1.69",36963,"asdasd","say ©255255255".$name.": ".$msg); 
} 
?> 

<html> 
    <form> 
     <input type="submit" value="send" name="send"> 
    </form> 
</html> 

“错误” 是:

说明:未定义变量:消息中d:\ XAMPP \ htdocs中\上线11 通知测试\ index.php的:未定义变量:在第14行D:\ xampp \ htdocs \ test \ index.php中的msg

回答

1

不要用'$'定义输入的ID。 PHP将其解释为一个变量。将其命名为'味精'。然后,您可以参考$_POST['msg']$_GET['msg'],具体取决于您将它发送到PHP文件的方式。