问题
I have this rewriterule in .htaccess
file
RewriteRule ^(.+)$ index.php?url=$1
Then, when I check type of $_GET['url']
, is always a string.
I interested to know whether or not it's possible, to write in the browser's address bar some magic symbols (or something like this) and obtain in $_GET['url']
an other type (not string)?
Or will the type of $_GET
always be string
?
回答1:
If you do this:
index.php?url=asd&url[]=asd //asd&url[]=asd being the dynamic part
Then $_GET['url']
will be an array.
回答2:
Whatever you take from $_GET
will always be a string.
回答3:
$_GET
parameters will always be strings.
But you could check if your variable is a number, and then use a cast:
if (is_numeric($_GET['url'])) {
$url = (int) $_GET['url'];
}
http://php.net/manual/en/function.is-numeric.php
http://php.net/manual/en/language.types.type-juggling.php
来源:https://stackoverflow.com/questions/13388933/type-of-get-variable