$_GET default value

Hello everyone

I would like to know if $_GET has a sort of a default value?

What I mean is this: I want to make my url as short as possible, something like

is this possible?

or it must be www.domain.com/?v=1


Or http://us2.php.net/manual/en/function.array-keys.php

You could use the PATH_INFO element in $_SERVER, given the URL:-


You could grab ‘banana’ like so…

$var = trim($_SERVER['PATH_INFO'], '/');

With a little dash of Apache’s mod_rewrite module thrown in, you could quite easily remove index.php from the URL.

Alternatively, you could still use the query string.


You could grab ‘banana’ like so…


thanks logic_earth

is there an easy way not to display this:
array(1) { [123]=> string(0) “” }

I tried $myvar= var_dump ($_GET) but it still displays it.

I went on php.net and checked var_dump examples. In one of them, they suggest to use var_export($_GET, true) do you think it’s ok?

Test it

<?php var_dump( $_GET );