php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #40405 htmlentities example is incorrect.
Submitted: 2007-02-08 17:12 UTC Modified: 2007-02-10 11:46 UTC
From: ar3121 at att dot com Assigned: colder (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ar3121 at att dot com
New email:
PHP Version: OS:

 

 [2007-02-08 17:12 UTC] ar3121 at att dot com
Description:
------------
On the htmlentities function documentation page:

http://us2.php.net/htmlentities

Example 2262 is incorrect.  The function call with and without ENT_QUOTES produces different results, but the documentation says they're the same.





Expected result:
----------------
<?php
$str = "A 'quote' is <b>bold</b>";

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str);

// Outputs: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);
?> 

Actual result:
--------------
<?php
$str = "A 'quote' is <b>bold</b>";

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str);

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);
?> 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-09 10:57 UTC] rquadling@php.net
The example is correct.

09/02/2007 11:00:05 C:\>php -n
<?php
$str = "A 'quote' is <b>bold</b>";

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str);

// Outputs: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);
?>
^Z
A 'quote' is &lt;b&gt;bold&lt;/b&gt;A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
 [2007-02-09 11:00 UTC] rquadling@php.net
If you run the code through a browser (I'm using FF on WinXP), then the screen shows ...

A 'quote' is <b>bold</b>A 'quote' is <b>bold</b>

But if you look at the actual HTML ...

A 'quote' is &lt;b&gt;bold&lt;/b&gt;A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;

Which matches the example.
 [2007-02-09 15:05 UTC] ar3121 at att dot com
Look closer... the actual html you just posted does not match the example.

Maybe it would help if you focused on just the second half of the example:

<?php
$str = "A 'quote' is <b>bold</b>";

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);
?>
 [2007-02-09 17:13 UTC] rquadling@php.net
Hmmm.

The most recently built Windows CHM and Extended CHM files show this correctly. The CVS was last changed in 2003, so this means that the web building mechanism is at fault somewhere.

But the page was last built in Dec 2006. It may need a rebuild.

I'll try and get this done.

 [2007-02-10 11:46 UTC] colder@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

There was an entity decoding mechanism in html_syntax.php, which is now removed. Thanks Hannes for the tests.

This also fixes htmlspecialchars' example.
 [2020-02-07 07:30 UTC] phpdocbot@php.net
Automatic comment on behalf of colder
Revision: http://git.php.net/?p=doc/base.git;a=commit;h=e3496c0df1356808a4930a476c67376dbce9932c
Log: - remove entities decoding - Fix #40405 (htmlentities example) - Fix htmlspecialchars example
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Sep 15 12:00:01 2025 UTC