Skip to content

Description of ENT_DISALLOWED in htmlentities is misleading #4547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mondolirondo opened this issue Mar 19, 2025 · 0 comments
Open

Description of ENT_DISALLOWED in htmlentities is misleading #4547

mondolirondo opened this issue Mar 19, 2025 · 0 comments

Comments

@mondolirondo
Copy link

From manual page: https://php.net/function.htmlentities

Description of ENT_DISALLOWED is misleading.
It states: "Replace invalid code points for the given document type with a Unicode Replacement Character U+FFFD (UTF-8) or &#FFFD; (otherwise) instead of leaving them as is. This may be useful, for instance, to ensure the well-formedness of XML documents with embedded external content."
It should say somenthing like: "Returns an empty string when invalid code points for the given document are found."

Tested using the following code:

$string = "This is a test: \x80\x81";
echo htmlentities($string, ENT_SUBSTITUTE, 'UTF-8');
// Output: This is a test: ��
echo "\n";
$string = "This is a test: \x80\x81";
echo htmlentities($string, ENT_DISALLOWED, 'UTF-8');
// Output: <empty line> 
echo "\n";
$string = "This is a test: xx";
echo htmlentities($string, ENT_DISALLOWED, 'UTF-8');
// Output: This is a test: xx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant