How to stop HTML text in textarea to be interpreted as code

Posted by Myone on Stack Overflow See other posts from Stack Overflow or by Myone
Published on 2014-05-29T21:14:54Z Indexed on 2014/05/29 21:26 UTC
Read the original article Hit count: 288

Filed under:
|
|

I have a textarea that users can edit. After the edit I save the text in a PHP variable $bio. When I want to display it I do this:

    <?php 
    $bio = nl2br($bio);
    echo $bio;
    ?>

But if a user for example types an HTML command like "strong" in their text my site will actually output the text as bold. Which is nothing I want.

How can I print/echo the $bio on the screen just as text and not as HTML code?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about php

Related posts about html