1.2.853. Non Ascii Variables¶
PHP allows certain characters in variable names. The variable name must only include letters, figures, underscores and ASCII characters from 128 to 255.
In practice, letters outside the scope of the intervalle [a-zA-Z0-9_]
are rare, and require more care when editing the code or passing it from OS to OS.
Also, certain letter might appear similar to the roman ones, and be part of a different alphabet. This is the case, for example, of the cyrillic alphabet, where А (cyrillic A, U+0410) is actually different from A (Latin A, U+0041). Some dashes and spaces may be valid in PHP variable names, and look very confusing.
<?php
// person, in Simplified Chinese
class 人 {
// An actual working class in PHP.
public function __construct() {
echo __CLASS__;
}
}
// people = new person();
$人民 = new 人();
?>
See also Variables.
1.2.853.1. Suggestions¶
Make sure those special chars have actual meaning.
1.2.853.2. Specs¶
Short name |
Variables/VariableNonascii |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Examples |
|
Available in |