Hi
I am trying to add a text in php where a "<" and ">" sign exits in a string, however when I view the string I get '%3C' and '%3E' respectively.

I tried most of the php functions related to html entities such as:
htmlentities
html_entity_decode
htmlspecialchars

I viewed the html signs table but never found that '<' is equivalent to '%3C' or '>' is equivalent to '%3E'. But rather I found they are equivalent to '&lt;' and '&gt;' respectively.

Recommended Answers

All 3 Replies

%3C and the link are url encoded, use url_decode to decode them.

thank you for the reply. it was really helpful. However, it seemed it did not work on my local server. I tried couple of online decoder and they worked. So any idea why it did not work on the local server?

I also tried rawurlencode but with no luck.

Basically I put this code in single page:

<?php
 $img  = "<img border=0 src=\"<#themepath#>/close.gif\">";
			 $re = urldecode($img);
			 echo $re;
			 ?>

And I got the same results. However when I changed ' < > ' to this ' { }' The first ' { ' was displayed as ' %7B ' while ' } ' was displayed normally, ie without any change.

why is this happening?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.