PDA

View Full Version : PHP get question



wibumba
08-06-2008, 03:44 AM
I'm making my php script display a page based on a get variable. I know I can do this by (for instance) "index.php?page=pics", but I remember seeing a script a month ago (I forget which site and how I found it) that retrieved a value from a URL like this "index.php?pics". How exactly would I do that?

Twey
08-06-2008, 04:47 AM
You can parse $_SERVER['QUERY_STRING'], or alternatively (less flexible) simply check for isset($_GET['pics']).

wibumba
08-06-2008, 05:11 AM
Ah yes, that's the one. Thanks.

Twey
08-06-2008, 05:18 AM
Oh, perhaps better than parsing QUERY_STRING:
$s = array_keys($_GET); // PHP doesn't allow us to do array lookup without an intermediate variable.
$s = @$s[0];