1

Code:

function getShopInfo()
    {
        $url = $this->env['url'] . "shop/get?partner_id=" . $this->partner_id . "&shopid=" . $this->shop_id . "&timestamp=" . $this->getTimestamp();
        echo $url;
    }

Result:

https://url.com/api/v2/shop/get?partner_id=99999&shopid=123456×tamp=1613629442

Why the output for &timestamp is printed as ×tamp?

amlxv
  • 1,610
  • 1
  • 11
  • 18

2 Answers2

2

& has special meaning in HTML, it's used to start an entity specification.

Use the htmlspecialchars() function to encode all the special characters so you can see them literally.

echo htmlspecialchars($url);
Barmar
  • 741,623
  • 53
  • 500
  • 612
1

Better yet, you should be using http_build_query() to build URL-encoded query strings. i.e:

function getShopInfo()
{
    $data = [
        "partner_id" => $this->partner_id,
        "shopid" => $this->shop_id,
        "timestamp" => $this->getTimestamp()
    ];

    $url =  $this->env['url'] . "shop/get?". http_build_query($data);
    echo $url;
}
steven7mwesigwa
  • 5,701
  • 3
  • 20
  • 34