php - 有没有办法在 php 中回显“×tamp”?
问题描述
代码:
function getShopInfo()
{
$url = $this->env['url'] . "shop/get?partner_id=" . $this->partner_id . "&shopid=" . $this->shop_id . "×tamp=" . $this->getTimestamp();
echo $url;
}
结果:
https://url.com/api/v2/shop/get?partner_id=99999&shopid=123456×tamp=1613629442
为什么输出×tamp
打印为×tamp
?
解决方案
&
在 HTML 中有特殊的含义,它用于启动实体规范。
使用该htmlspecialchars()
函数对所有特殊字符进行编码,以便您可以从字面上看到它们。
echo htmlspecialchars($url);
推荐阅读
- php - 在本地机器上工作但抛出:目标类 [App\Http\Controllers\JobsController] 不存在。在 Heroku 上
- python - 在 python 2.7 中使用 Super(Subclass, self) 的多重继承
- javascript - 使用模块时如何调用 body.onload?
- python - 在 Flask (Python) 中为不同的 html 选项创建 if 语句
- javascript - 反应错误 - Uncaught SyntaxError: Unexpected token o in JSON at position 1
- ios - 更新 Binding 时未发生 SwiftUI 动画
- android - 从 strings.xml 获取 JSON URL 链接到 HTTP 请求
- azure-container-service - AKS api 服务授权的 ip 范围是否自动包含 azure devops?
- java - 带有 Spring Security 的 Java SpringBoot Websocket
- laravel - 重定向中间件路由在 Laravel 中不起作用