- substr: documentation ( source)
- parse_str: documentation ( source)
- htmlentities: documentation ( source)
<?php
// forcing a SERVER variable:
$_SERVER['QUERY_STRING'] = '?query=string';
$qs = htmlentities( $_SERVER['QUERY_STRING'] );
$str = substr( $qs, 1 ); // remove the '?'
// array option
parse_str( $str ,$arr);
echo $arr['query'],"\n";
// variable option
parse_str( $str );
echo $query;