I'm afraid you can’t. All parameters sent with the request have a type string.
You can send parameters as JSON encoded.
Assuming Object
{"int":1}
urlencoded it
%7B%22int%22%3A1%7D
Send request http://domain.org/params=%7B%22int%22%3A1%7D
on domain.org decodes it:
$params=json_decode($_GET['params']);
And you will see that the type is still integer:
echo gettype($params->int);
But this is somehow also a conversion from the server (because you need to decode JSON).
As for the comment below, here is an example that shows that this is not a pig with lipstick, try and see if the types persist:
<html>
<head>
<title>Test</title>
<script type="text/javascript">
<!--
function request()
{
var obj={
"pig":1,
"cow":2.2,
"duck":'donald',
"rabbit":{"ears":2}
};
location.replace('?params='+encodeURIComponent(JSON.stringify(obj)));
}
</script>
</head>
<body>
<input type="button" onclick="request()" value="click">
<pre><?php
if(isset($_GET['params']) && $params=json_decode($_GET['params']))
{
var_dump($params);
}
?>
</pre>
</body>
</html>
Conclusion:
object(stdClass)#1 (4) {
["pig"]=>
int(1)
["cow"]=>
float(2.2)
["duck"]=>
string(6) "donald"
["rabbit"]=>
object(stdClass)#2 (1) {
["ears"]=>
int(2)
}
}
, , , JSON "" .