Search code examples
phpurlget

how to get complete value in a variable in the page url php


I have this URL in my page

https://www.albaama.com/search.php?qry=Fashion%20&%20Clothing

and I use this code below to echo out the value of the variable 'qry'

<?php 
    if (isset($_GET['qry'])) {
        echo $_GET['qry'];
    } 
    else {
        echo "";
    } 
?>

but whenever I echo it, I only get Fashion instead of Fashion & Clothing. please how do I get the complete value?


Solution

  • This query string: https://www.albaama.com/search.php?qry=Fashion%20&%20Clothing

    Translates to this:

    The problem is that & introduces a second parameter.

    You need to urlencode() the entire string "Fashion & Clothing"