Tagged: ,

This topic contains 0 replies, has 1 voice, and was last updated by  Shubham Kumar 1 year, 1 month ago.

  • Author
    Posts
  • #2415 Reply

    Shubham Kumar

    Hi,

    Actually I was configuring my Around the Web Plugins Demo Page and found that dot(.) is getting replaced with underscore(_) in php $_GET.

    Now, I have fixed the problem.

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

    [php]$query = file_get_contents(‘php://input’);[/php]

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

    You can then parse it if you need

    [php]
    <?php
    // Function to fix up PHP’s messing up input containing dots, etc.
    // $source can be either ‘POST’ or ‘GET’
    function getRealInput($source) {
    $pairs = explode("&amp;", $source == ‘POST’ ? file_get_contents("php://input") : $_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;
    }
    // Wrapper functions specifically for GET and POST:
    function getRealGET() { return getRealInput(‘GET’); }
    function getRealPOST() { return getRealInput(‘POST’); }
    ?>
    [/php]

    Source: Stackoverflow

Reply To: Why does PHP Replaces dot(.) with an underscore(_) if it’s a key in $_GET?
Your information:




shares