0

Before that, I searched around for problem same as me, but not found any..

I got a url http://mywebsite/rpc.php?stat=22

then, I have this code:

if(isset($_GET['stat'])){
$id = preg_replace("/[^0-9]/", "", $_GET['stat']);
$result = $rpc->get($id);
print_r($result);
}

this code will print array without result.. But, If I modify the code like this :

if(isset($_GET['stat'])){
//$id = preg_replace("/[^0-9]/", "", $_GET['stat']);
$result = $rpc->get(22);
print_r($result);
}

it will print the result as I want.. I tried echoing $_GET,and it output number 22.. is there anybody know what is the problem with my script?

this is the code that will process $rpc->get();

public function get ( $ids = array(), $fields = array() )
{
if ( !is_array( $ids ) ) $ids = array( $ids );  // Convert $ids to an array if only a single id was passed
if ( count( $fields ) == 0 ) $fields = array( "id", "name", "downloadDir", "rateDownload", "status", "doneDate", "haveValid", "totalSize" );    // Defaults
$request = array(
"fields" => $fields,
"ids" => $ids
);
return $this->request( "torrent-get", $request );
}
4

1 回答 1

2

您的$rpc->get方法似乎需要一个整数作为参数,您可以$_GET像这样从全局获取它:

$id = intval(preg_replace("/[^0-9]/", "", $_GET['stat']));
于 2013-11-14T01:02:33.153 回答