phphtmlurl

How to get &curren to display literally, not as an HTML entity


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?


Solution

  • 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