Describe how non-ASCII variable names behave instead of asserting they are unsupported - #5831
Merged
Merged
Conversation
The note claimed PHP "doesn't support Unicode variable names" and then explained that they work anyway. Replace it with a description of the observable behaviour.
TimWolla
approved these changes
Sep 3, 2026
lacatoire
reviewed
Sep 4, 2026
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Contributor
Author
|
You're right, and thank you for catching it -- "other encodings" was too So it holds for Latin-1 and EUC-JP, whose non-ASCII bytes are all >= 0x80, |
Member
|
LGTM. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current note says PHP "doesn't support Unicode variable names" and then
explains that they work anyway. That leaves a reader with
$größein theircodebase unable to tell what the language actually guarantees.
This replaces the assertion with a description of the observable behaviour:
names are compared as bytes, the encoding is neither interpreted nor
validated, and two names that render identically can be distinct. All three
statements are checkable against the engine today.
It deliberately makes no claim about whether non-ASCII names are a supported
feature. That question is currently open on internals and the manual should
not pre-empt it in either direction:
https://news-web.php.net/php.internals/132344
The look-alike hazard is not hypothetical. In a survey of the 5,000
most-downloaded Packagist packages (520,802 files), 68 identifiers contain an
invisible character. One live example is the Alipay OpenAPI SDK, which assigns
to
$chrtextwith a trailing U+00A0 and then passes that variable byreference, so anyone typing the name without the no-break space gets a
silently different variable. Data and tooling: https://github.com/Otzie2023/PHP