0

I am trying to see the restrictions of $_GET global variable and when I use the URL localhost/test/test.php?abc.def I am getting the variable abc_def in the global variable $_GET, any ideas? Any other restrictions?

2
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by OmniX
0

http://us3.php.net/variables.external

Explains why those periods are converted to underscores.
Through the comments there are also other characters that are mentioned that appear to be converted as well.

Thanks was useful, how to counter the restrictions being converted to a _?

1

It looks like only POST values get sent to php://input.
I reworked the function so it gets it's values from the $_SERVER variable.

<?php
function getRealGet()
{
	$pairs = explode( '&', $_SERVER['QUERY_STRING'] );
	$vars = array();
	foreach ($pairs as $pair) {
		$nv = explode("=", $pair);
		$name = urldecode($nv[0]);
		$value = urldecode($nv[1]);
		$vars[$name] = $value;
	}
	return $vars;
}

var_dump( getRealGet() );
Votes + Comments
nice code example
0

That what I have been testing with using "$_SERVER" there must be more of a efficient way? Thanks for the edited function.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.