Before I really answer your question, I just have to say that most sites - at least that I have seen - actually use ?43892
, with the =
. This is also much easier than using it with =
in my opinion.
So, now to the actual answer. You can simply extra the query string using $_SERVER['QUERY_STRING']
.
An example:
User requests index.php?12345
:
<?php
echo $_SERVER['QUERY_STRING'];
?>
Output:
12345
Note that you can also use something like
<?php
if(substr($_SERVER['QUERY_STRING'], 0, 1) == '=') {
$query_string = substr($_SERVER['QUERY_STRING'], 1);
}else{
$query_string = $_SERVER['QUERY_STRING'];
}
echo $query_string;
to support ?=12345
as well as 12345
, with the same result. Note also that ?=12345
would not be available as $_GET['']
either.