Run ECHO without interpreting HTML

Asked

Viewed 657 times

3

I have a value in mysql database that contains some html commands like:

<b>Olá</b>

<br>

Other...

I need that when I show the value using <?php echo $row_rs['original']; ?> appear exactly like this in the BD, without the HTML interpretation.

Instead of showing up like this:

Hello

appear like this:

<b>Olá</b>

Thank you.

1 answer

12


Use htmlentities.

Ex.: <?php echo htmlentities($row_rs['original']); ?>

  • how do I limit and echo to 35 characters?

  • @James to limit: echo substr(htmlentities($row_rs['original']), 0, 35);

  • thanks, thank you very much!

  • +1 for the correct solution. It is worth mentioning to those who are not familiar with the technologies involved that in fact what is being done is not to avoid interpreting HTML, but to give escape in HTML with more HTML :).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.