Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ PHP NEWS
(mehmetcansahin)
. Improved performance of resolving the charset of HTML functions,
especially UTF-8. (Nicolas Grekas)
. Improved performance of htmlspecialchars() when nothing needs encoding.
(Nicolas Grekas)

- URI:
. Fix casing of enum cases in UriHostType and UrlHostType to match the RFC
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ PHP 8.7 UPGRADE NOTES
. Improved performance of htmlspecialchars(), htmlentities(),
html_entity_decode() and get_html_translation_table(), especially with
UTF-8.
. htmlspecialchars() returns its input without copying it when nothing needs
encoding.

- MBString:
. Improved performance of mb_strlen for UTF-8 strings.
2 changes: 0 additions & 2 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,6 @@ static const func_info_t func_infos[] = {
F1("inet_pton", MAY_BE_STRING|MAY_BE_FALSE),
F1("metaphone", MAY_BE_STRING),
F1("headers_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("htmlspecialchars", MAY_BE_STRING),
F1("htmlentities", MAY_BE_STRING),
F1("get_html_translation_table", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING),
F1("bin2hex", MAY_BE_STRING),
F1("hex2bin", MAY_BE_STRING|MAY_BE_FALSE),
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2273,14 +2273,12 @@ function headers_list(): array {}

/* {{{ html.c */

/** @refcount 1 */
function htmlspecialchars(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ?string $encoding = null, bool $double_encode = true): string {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a typical web-application the htmlspecialchars function usually is invoked a lot. maybe its worth to make it frameless?

@nicolas-grekas nicolas-grekas Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be worth it after this one is merged - the call overhead will then be significant enough.
As a separate PR.
FTR, frameless variants exist only for 1 to 3 arguments. Twig passes 3, Laravel's e() 4, so it wouldn't benefit there.


function htmlspecialchars_decode(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401): string {}

function html_entity_decode(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ?string $encoding = null): string {}

/** @refcount 1 */
function htmlentities(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ?string $encoding = null, bool $double_encode = true): string {}

/**
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/basic_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions ext/standard/basic_functions_decl.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading