0

The question is this, i have some text that i bring from the DB. The info is recorded as HTML. When i bring that info, it comes as "<b>hello world</b>" i mean, it comes all the html as string, and i want to use that string as html. I think there is a function in php for this, but i dont find.

example: i have "<b>hello world</b>" and need to be hello world

5
  • 1
    Did you look at your source code in the browser? Commented May 4, 2011 at 6:04
  • Check content-type. Try header('Content-type: text/html'); in start of output. Commented May 4, 2011 at 6:22
  • the browser source code shows: "&lt;td class=&quot;d&quot; style=&quot;font-family: Arial, Verdana, sans-serif; padding: 0pt; margin: 0pt;&quot;&gt; ", i have to convert the &lt to < and all those special chars Commented May 4, 2011 at 6:25
  • Where do you put it in the document? Commented May 4, 2011 at 6:42
  • when you say When I bring that info, it comes as "<b>hello world</b>", what are you using to "bring in that info"? Sure, you could do a simple preg_replace() to kill the bold tags, but lets try to get to the ROOT of the problem... Please give us some code to work with here... Commented May 4, 2011 at 6:48

3 Answers 3

3

You can use:

echo htmlspecialchars_decode($var);

I think you use htmlspecialchar() when you insert to database

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

Comments

0

See the functions

Guess that should solve your problem ;)

As from the PHP Manual:

<?php 
  $orig = "I'll \"walk\" the <b>dog</b> now";
  $a = htmlentities($orig);
  $b = html_entity_decode($a);
  echo $a; // I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now
  echo $b; // I'll "walk" the <b>dog</b> now
?>

1 Comment

i want the opposite of htmlentities, but the unhtmlentities shows nothing
0

if you are doing an

<?php echo "<b>Hello World</b>" ?>

in your php page, it will be interpreted as html. So there is no problem ;)

1 Comment

you should accept correct/acceptable answers when you ask a question

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.