如何让& curren字面显示,而不是HTML实体 [英] How to get &curren to display literally, not as an HTML entity

查看:1330
本文介绍了如何让& curren字面显示,而不是HTML实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用php来查看其中包含网址的XML文件。这些网址看起来像这样:



https://site.com/bacon_report?Id=1&report=1&currentDimension=2&param=1



当我回显网址时,& curren显示为¤(也就是#164,A4或货币符号),链接不起作用。即使没有关闭分号,也会发生这种情况。从字面上制作& curren显示最干净的方法是什么?

解决方案

使用php函数urlencode:

  urlencode(https://site.com/bacon_report?Id=1&report=1&currentDimension=2&param=1


会输出%3FId%3D1%26report%3D1%26currentDimension%3D2%26param%3D1


I'm using php to look at an XML file that has a URL in it. The URLs look something like this:

https://site.com/bacon_report?Id=1&report=1&currentDimension=2&param=1

When I echo out the URLs, the "&curren" shows up as "¤" (AKA #164, A4 or currency symbol) and the links don't work. This happens even though there isn't a closing semicolon for it. What is the cleanest way to make "&curren" display literally?

解决方案

Use the php function urlencode:

urlencode("https://site.com/bacon_report?Id=1&report=1&currentDimension=2&param=1"

will output

https%3A%2F%2Fsite.com%2Fbacon_report%3FId%3D1%26report%3D1%26currentDimension%3D2%26param%3D1 

这篇关于如何让& curren字面显示,而不是HTML实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆