-4

I am trying to convert html entities but its not working.

$string_with_bold_tag = "<b>Hello World </b&gt";
$converted = html_entity_decode($string_with_bold_tag);

echo $converted;

Its only return Hello World with bold tag. Any idea what i am doing wrong?

3
  • what is your expected result? the entities have been decoded, so the tags will be parsed as HTML
    – adjan
    Jun 21, 2014 at 16:03
  • @addy2012: i need this string with bold formatting.. currently it return just Hello World. if i remove html_entity_decode than it return as like <b>Hello World</b>
    – devpro
    Jun 21, 2014 at 16:08
  • i got the solution, solution is that, if any tag is not working on webpage than check css, and change the type of font. bold tag is not working when your font type is font: inherit
    – devpro
    Jun 21, 2014 at 16:38

3 Answers 3

3

Your string have an issue in the syntax, try this:

$string_with_bold_tag = "&lt;b&gt;Hello World &lt;/b&gt;"; //you missed a semi colon here
$converted = html_entity_decode($string_with_bold_tag);

echo $converted;

At the end of your input string there was no semicolon &gt -> &gt ;

In order to be interpreted correctly you need the right syntax.

3
  • 1
    thank you @mayerz, it return as like that now <b>Hello World</b>
    – devpro
    Jun 21, 2014 at 16:22
  • but i dont understand why my webpage not converted as like Hello World
    – devpro
    Jun 21, 2014 at 16:23
  • 2
    i got the solution, solution is that, if any tag is not working on webpage than check css, and change the type of font. bold tag is not working when your font type is font: inherit .... thanks for your support
    – devpro
    Jun 21, 2014 at 16:39
1

Check your css file and change the type of your font which you are using in template. It should not be:

font: inherit;
0
0

You are missing an additional ';' at the end of your string

Should be:

$string_with_bold_tag = "&lt;b&gt;Hello World &lt;/b&gt;";

When you decode it you should get:

<b>Hello World </b>
1
  • thankk you @motti, for your support.. i got the solution, solution is that, if any tag is not working on webpage than check css, and change the type of font. bold tag is not working when your font type is font: inherit
    – devpro
    Jun 21, 2014 at 16:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.