I have wordpress template in which url is generating in for of xyz.com/?pickup_location=662#038;pickup_date=2018%2F08%2F08&return_date=2018%2F08%2F10

now I want to get pickup_date but I could not I also tried $_SERVER['REQUEST_URI'] but it's giving link till pickup_location

Dani AI

Generated

Short answer: the visible #038; is a mangled HTML entity that effectively inserts a # (fragment marker) into the link, so the browser treats everything after it as a fragment and never sends those parts to the server. That is why neither $_GET nor $_SERVER['REQUEST_URI'] show the pickup_date parameter. was right to point you at the code that builds the URL — fix the generator instead of trying to parse a broken URL on the server.

Quick checks to confirm the problem

  • View page source / Inspect element and check the anchor href. If the href literally contains #038; (or an unescaped #) that is the problem.
  • Use the browser Network tab (click the link) to see the exact request URL the browser sends — it will stop at the #.
  • $_SERVER['QUERY_STRING'] / $_GET will never include fragment content; that explains the truncated values you saw.

How to fix (recommended)

  • In WordPress, build the query with add_query_arg() and output with esc_url() so separators are handled correctly and values are encoded. Do not double-escape the whole URL.
    $params = array(
    'pickup_location' => 662,
    'pickup_date'     => '2018/08/08',
    'return_date'     => '2018/08/10',
    );
    $url = add_query_arg( $params, home_url( '/' ) );
    echo '<a href="' . esc_url( $url ) . '">Book</a>';

If you are not in WP:

$params = [
  'pickup_location' => 662,
  'pickup_date'     => '2018/08/08',
  'return_date'     => '2018/08/10',
];
$url = 'https://example.com/?' . http_build_query( $params, '', '&', PHP_QUERY_RFC3986 );
echo '<a href="' . htmlspecialchars( $url, ENT_QUOTES, 'UTF-8' ) . '">Book</a>';

If you cannot change the generator right away, a client-side replace is a temporary hack (not a fix):

document.addEventListener('click', function(e){
  var a = e.target.closest('a');
  if (!a) return;
  if (a.href.indexOf('#038;') !== -1){
    e.preventDefault();
    window.location.href = a.href.replace('#038;', '&');
  }
});

Final note: the long-term fix is to stop the double/incorrect encoding at source. Correctly build the query string (use add_query_arg / http_build_query) and escape only for HTML output — then $_GET will work reliably.

Strange encoding here. Look at the code that generates this url to see why it's giving you this. Better to treat the cause not the symptom.

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.