0

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()

&lt;img src=http://14fc272d-131b-47ce-b452-9cd47a4a3846.jpg&gt;<div><br></div><div><br></div><div><br></div><div>&lt;iframe width=420 height=315 src=http://www.youtube.com/embed/LBBqOTd5qzE frameborder=0 allowfullscreen&gt;&lt;/iframe&gt;</div>

Any ideas how to convert them into the said images/iframe videos etc.

1
  • Try to use htmlspecialchars() Commented Nov 26, 2012 at 11:19

2 Answers 2

1

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()

Sign up to request clarification or add additional context in comments.

2 Comments

It works fine. You echo it into <textarea> then it is not processed but taken literaly as just text. You cannot have images etc in textarea
I am echoing from <textarea>. You will see I am using NiceEdit.com RTE
0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.