IntlChar::getPropertyName()函數是PHP中的內置函數,用於獲取Unicode數據庫文件PropertyAliases.txt中給定屬性的Unicode名稱。此函數將屬性IntlChar::PROPERTY_GENERAL_CATEGORY_MASK映射到PropertyAliases.txt中不在的綜合名稱“gcm” /“General_Category_Mask”。此函數是對IntlChar::getPropertyEnum()函數的補充。
用法:
string IntlChar::getPropertyName( $property, $nameChoice = IntlChar::LONG_PROPERTY_NAME )
參數:該函數接受上述和以下描述的兩個參數:
- $property:此參數保存Unicode屬性常量(IntlChar::PROPERTY_ *常量)
屬性常量的列表為:- IntlChar::PROPERTY_ALPHABETIC
- IntlChar::PROPERTY_BIDI_MIRRORED
- IntlChar::PROPERTY_BIDI_CLASS
- IntlChar::PROPERTY_DASH
- IntlChar::PROPERTY_IDEOGRAPHIC
- IntlChar::PROPERTY_LOWERCASE
- IntlChar::PROPERTY_MATH
- IntlChar::PROPERTY_UPPERCASE
- IntlChar::PROPERTY_WHITE_SPACE等…
除了其他unicode屬性外,不應使用IntlChar::PROPERTY_INVALID_CODE。
- $nameChoice此參數保存選擇器,該選擇器獲取哪個Unicode名稱。
返回值:如果屬性或名稱選擇超出範圍,則此函數在成功時返回名稱或False。
以下示例程序旨在說明PHP中的IntlChar::getPropertyName()函數:
示例1:
<?php
// Program illustrates the IntlChar::getPropertyName() function
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_MIRRORED));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_MIRRORED,
IntlChar::SHORT_PROPERTY_NAME));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_MIRRORED,
IntlChar::LONG_PROPERTY_NAME));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_MIRRORED,
IntlChar::LONG_PROPERTY_NAME + 1));
?>
輸出:
string(13) "Bidi_Mirrored" string(6) "Bidi_M" string(13) "Bidi_Mirrored" bool(false)
示例2:
<?php
// Program illustrates the IntlChar::getPropertyName() function
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_IDEOGRAPHIC));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_IDEOGRAPHIC,
IntlChar::SHORT_PROPERTY_NAME));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_IDEOGRAPHIC,
IntlChar::LONG_PROPERTY_NAME));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_IDEOGRAPHIC,
IntlChar::LONG_PROPERTY_NAME + 1));
?>
輸出:
string(11) "Ideographic" string(4) "Ideo" string(11) "Ideographic" bool(false)
示例3:
<?php
// Program illustrates the IntlChar::getPropertyName() function
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_GENERAL_CATEGORY_MASK));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_GENERAL_CATEGORY_MASK,
IntlChar::SHORT_PROPERTY_NAME));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_GENERAL_CATEGORY_MASK,
IntlChar::LONG_PROPERTY_NAME));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_GENERAL_CATEGORY_MASK,
IntlChar::LONG_PROPERTY_NAME + 1));
?>
輸出:
string(21) "General_Category_Mask" string(3) "gcm" string(21) "General_Category_Mask" bool(false)
相關用法
- PHP IntlChar::ord()用法及代碼示例
- PHP IntlChar::chr()用法及代碼示例
- PHP IntlChar getPropertyEnum()用法及代碼示例
- PHP IntlChar enumCharNames()用法及代碼示例
- PHP IntlChar::isIDPart()用法及代碼示例
- PHP IntlChar::isIDStart()用法及代碼示例
- PHP IntlChar::isISOControl()用法及代碼示例
- PHP IntlChar::isULowercase()用法及代碼示例
- PHP IntlChar::charAge()用法及代碼示例
- PHP IntlChar::charMirror()用法及代碼示例
- PHP IntlChar hasBinaryProperty()用法及代碼示例
- PHP IntlChar::isIDIgnorable()用法及代碼示例
- PHP IntlChar::charName()用法及代碼示例
- PHP IntlChar::isUWhiteSpace()用法及代碼示例
- PHP IntlChar::isUAlphabetic()用法及代碼示例
注:本文由純淨天空篩選整理自VigneshKannan3大神的英文原創作品 PHP | IntlChar getPropertyName() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。