Reputation: 22050
I am echoing the below using nicedit.com
<img src=http://images/14fc272d-131b-47ce-b452-9cd47a4a3846.jpg>
<iframe width=420 height=315 src=http://www.youtube.com/embed/LBBqOTd5qzE frameborder=0 allowfullscreen></iframe>
It ends up as just as code.
I tried nl2br()
but its still text.
Using htmlspecialchars()
<img src=http://14fc272d-131b-47ce-b452-9cd47a4a3846.jpg><div><br></div><div><br></div><div><br></div><div><iframe width=420 height=315 src=http://www.youtube.com/embed/LBBqOTd5qzE frameborder=0 allowfullscreen></iframe></div>
Any ideas how to convert them into the said images/iframe videos etc.
Upvotes: 0
Views: 597
Reputation: 377
I think you actually want to show that codes on Browser. without executing it.. It could be your solution:-
<pre>
<img src=http://images/14fc272d-131b-47ce-b452-9cd47a4a3846.jpg>
<iframe width=420 height=315 src=http://www.youtube.com/embed/LBBqOTd5qzE frameborder=0 allowfullscreen></iframe>
</pre>
Upvotes: 0
Reputation: 75645
Use htmlspecialchars()
to convert special chars to entities. Also, start quoting tags' attributes:
<img src="http://images/14fc272d-131b-47ce-b452-9cd47a4a3846.jpg">
<iframe width="420" height="315" src="http://www.youtube.com/embed/LBBqOTd5qzE" frameborder="0" allowfullscreen></iframe>
You may also want to back allowfullscreen
with webkitallowfullscreen mozallowfullscreen
as well.
EDIT
I am echoing from
<textarea>
Ok, you then already got entities (your question wasn't clear enough). You need the opposite to htmlspecialchars()
then, which is html_entity_decode()
or htmlspecialchars_decode()
Upvotes: 1