首页 > 解决方案 > 有没有办法在 php 中回显“×tamp”?

问题描述

代码:

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

结果:

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

为什么输出&timestamp打印为×tamp

标签: php

解决方案


&在 HTML 中有特殊的含义,它用于启动实体规范。

使用该htmlspecialchars()函数对所有特殊字符进行编码,以便您可以从字面上看到它们。

echo htmlspecialchars($url);

推荐阅读