我正在尝试制作脚本,我想显示从URL插入的gameserver ip的信息。
在当前配置中我有:
<?php
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery :: SOURCE );
define( 'SQ_SERVER_ADDR', '123.45.67.890' );
define( 'SQ_SERVER_PORT', 12345);
?>
和我这样尝试:
<?php
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery :: SOURCE );
if (isset($_GET['ip'])){
$ip = $_GET['ip'];
}
if (isset($_GET['port'])){
$port = $_GET['port'];
}
define( 'SQ_SERVER_ADDR', $ip );
define( 'SQ_SERVER_PORT', $port );
?>
与
相似http://localhost/".$ip.":".$port.
而不是固定ip。插入"define"
你不能让你的url为localhost/$ip:$port
您将需要它作为localhost/addr=$IP:$PORT
,因为您正在使用$_GET
用下面的代码修改你的代码:
<?php
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery :: SOURCE );
if (isset($_GET['addr'])){
$addr = $_GET['addr'];
$addrarray = explode(':', $myString);
$ip = $addrarray[0];
$port = $addrarray[1];
}
define( 'SQ_SERVER_ADDR', $ip );
define( 'SQ_SERVER_PORT', $port );
?>
现在将您的地址设置为:
我使用一个示例ip: 192.168.0.0还有一个示例端口:1234
localhost/addr=192.168.0.0:1234
希望有帮助