Recommend this page to a friend! |
Classes of jawira | PHP Case Convert | docs/case-mapping.md | Download |
|
DownloadCase-MappingIntroduction>Case mapping or case conversion is a process whereby strings are converted to a particular form?uppercase, lowercase, or titlecase?possibly for display to the user. PHP always performed _Simple Case-Mapping_, this is map one-to-one character mapping. For example, one _lower case_ character is converter to one _upper case_ character. PHP 7.3 introduced [Full Case-Mapping], you can have one-to-many character mapping. In practice this means than you can have different results depending on your PHP version.
Please note that _Full Case-Mapping_ is locale dependent:
Forcing _Simple Case-Mapping_As told before, _Full Case-Mapping_ is only available on PHP 7.3 and newer. The following code snippet is executed on PHP 7.3:
To force _Simple Case-Mapping_ you have to call
Please note Technical detailsInternally
The problem is that, Before _PHP 7.3_, these constants perform simple case-mapping and after _PHP 7.3_ perform full case-mapping. If you want to maintain the old functionality after _PHP 7.3_ you have to call
* IMHO this is a _breaking change_, PHP people should have keep untouched old
constants and create new ones for [Full Case-Mapping], for example:
[Full Case-Mapping]: https://www.php.net/manual/en/migration73.new-features.php#migration73.new-features.mbstring.case-mapping-folding [mb_convert_case()]: https://www.php.net/manual/en/function.mb-convert-case.php |