Question

http://text.com/text/index.php?route=common/response&DR=5Uijhnk+t1j3lFFFEf4RB3zYyX

I'm trying to get value of DR i.e 5Uijhnk+t1j3lFFFEf4RB3zYyX

So far i've tried,

echo $_GET['DR']

But it's not printing anything !! Any way to get the value of DR

var_dump($_GET);

giving me below results,

array
  'route' => string 'common/response' (length=15)
Was it helpful?

Solution

Try this way

    $current_uri = $_SERVER['REQUEST_URI'] 
  // $current_uri = http://text.com/text/index.php?route=common/response&DR=5Uijhnk+t1j3lFFFEf4RB3zYyX

    $parsed_url = parse_url($current_uri);
    print_r($parsed_url);
    /* Array
    (
        [scheme] => http
        [host] => text.com
        [path] => /text/index.php
        [query] => route=common/response&DR=5Uijhnk+t1j3lFFFEf4RB3zYyX
    ) */

   $query = array();
   parse_str($parsed_url['query'], $query); // parse url string

   print_r($query);
   /* Array
    (
      [route] => common/response
      [DR] => 5Uijhnk+t1j3lFFFEf4RB3zYyX
    ) */

OTHER TIPS

try wirth Double-quotes & not single quotes

http://www.php.net/manual/en/reserved.variables.get.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top