can I get PHP to stop replacing ‘.’ characters in $_GET or $_POST arrays?

Mar 12, 2012   //   by   //   Blog, PHP Tutorial  //  No Comments

PHP lets you at the raw input stream, so you can do something like this:

$query_string = file_get_contents('php://input');

which will give you the $_POST array in query string format, periods as they should be.

You can then parse it if you need

// Function to fix up PHP's messing up POST input containing dots, etc.
function getRealPOST() {
    $pairs = explode("&", file_get_contents("php://input"));
    $vars = array();
    foreach ($pairs as $pair) {
        $nv = explode("=", $pair);
        $name = urldecode($nv[0]);
        $value = urldecode($nv[1]);
        $vars[$name] = $value;
    return $vars;

Hugely useful for OpenID parameters, which contain both ‘.’ and ‘_’, each with a certain meaning!

Leave a comment

Share This Post

RSS Wordpress News