tags:

views:

56

answers:

1

I have a problem as described below

  1. Users fill in information in a html textarea.
  2. Sometimes they enter code in the textarea.

    eg. <script src="fancybox/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>

  3. Now I want to display the output in a browser using PHP and the browser does not treat this as text but as code.

Is there a way to display this as text using php?

+10  A: 

Yes, you can use the htmlspecialchars function.

Ignas R
you were faster, +1 from me, welcome to stackoverflow!
Paul Dixon
+1 For naming `htmlspecialchars` and not `htmlentities`.
Gumbo
Thx for this answer, I somehow got confused between htmlspecialchars and htmlentities
Roland
Paul, thanks a lot for the welcome!
Ignas R