Php htmlentities function

software development


I have not been able to get the PHP function htmlentities to make any changes in the text passed to it in the first parameter. I took these two lines of code from the php manual entry for html entities. I put them into the php file that runs on my site on Marge when a form is returned to the directory. The code is:

$str = “A ‘quote’ is bold”;
echo htmlentities($str);

this returns:
“A ‘quote’ is bold

I.E. the string is unchanged. My site is actually on a mirror right now (http://…/

The experienced programmer in me says there is something going on here that I’m overlooking. The frustrated boy in me thinks the htmlentities function has been replaced with code that does nothing.

Your help will be appreciated.



What you are seeing, in the example given above, may have something to do with the PHP magic_quotes setting. At DH, by default, the 4.42 version of PHP is set up to handle this differently then the PHP5 version.

Searching google for “php htmlentities magic quotes” (without the quotes) leads to “a lot” of discussion of the interaction between htmlentities and magic_quotes.

(Edited: I had a link in there, but the forum software “borked” it :frowning: )

What version of PHP are you using?



phpinfo() says PHP version 5.1.2. Under PHP Core, magic_quotes_gpc is local value: off, and master value off. Also magic_quotes_runtime is off and off, as is magic_quotes_sybase.

Now I’m going to google magic quotes as you suggest.


No. Look at your source code, not the browser. it says:

A ‘quote’ is bold



Ah, yes. You got it. Firefox displayed the & lt;b& gt;bold& lt;/b& gt (in fact, I had to add spaces here to get the text to display without translating) as bold. That is the kind of simple solution I expected to this. More investigation shows IE does the same as Firefox. I wondered why Firefox was showing bold instead of “bold” actually bolded.
Terry, thank you.



Thats kind of the point of htmlentities to stop html codes from working.

My website