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?

Recommended Answers

All 6 Replies

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.

commented: useful link, thanks. +4

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 _?

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() );
commented: nice code example +4

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.