IntlChar::charDirection()函數是PHP中的一個內置函數,用於獲取代碼點的雙向類別值。它返回代碼點的雙向類別值,該值在Unicode雙向算法中使用。
用法:
int IntlChar::charDirection ( $codepoint )
參數:該函數接受單個參數$codepoint,該參數是必需的。 $codepoint值是整數值或字符,被編碼為UTF-8字符串。
返回值:此函數返回雙向類別值,如下所示:
- IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT
- IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT
- IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER
- IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR
- IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR
- IntlChar::CHAR_DIRECTION_ARABIC_NUMBER
- IntlChar::CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR
- IntlChar::CHAR_DIRECTION_BLOCK_SEPARATOR
- IntlChar::CHAR_DIRECTION_SEGMENT_SEPARATOR
- IntlChar::CHAR_DIRECTION_WHITE_SPACE_NEUTRAL
- IntlChar::CHAR_DIRECTION_OTHER_NEUTRAL
- IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING
- IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE
- IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC
- IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING
- IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE
- IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT
- IntlChar::CHAR_DIRECTION_DIR_NON_SPACING_MARK
- IntlChar::CHAR_DIRECTION_BOUNDARY_NEUTRAL
- IntlChar::CHAR_DIRECTION_FIRST_STRONG_ISOLATE
- IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE
- IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE
- IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE
- IntlChar::CHAR_DIRECTION_CHAR_DIRECTION_COUNT
以下示例程序旨在說明PHP中的IntlChar::charDirection()函數:
程序1:
<?php
// PHP code to illustrate IntlChar::charDirection()
// function
// Input data is character type
var_dump(IntlChar::charDirection("A") ===
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT);
// Input data is unicode character
var_dump(IntlChar::charDirection("\u{05E9}") ===
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT);
// Input data is character type
var_dump(IntlChar::charDirection("+") ===
IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR);
// Input data is character type
var_dump(IntlChar::charDirection(".") ===
IntlChar::CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR);
// Input data is string type
var_dump(IntlChar::charDirection("ABC") ===
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT);
// Input data is character type
var_dump(IntlChar::charDirection("c") ===
IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT);
// Input data is character type
var_dump(IntlChar::charDirection("O") ===
IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT);
?>
輸出:
bool(true) bool(true) bool(true) bool(true) bool(false) bool(false) bool(true)
程序2:
<?php
// PHP code to illustrate IntlChar::charDirection()
// function
// Input data is character type
var_dump(IntlChar::charDirection("A"));
// Input data is unicode character
var_dump(IntlChar::charDirection("\u{05E9}"));
// Input data is character type
var_dump(IntlChar::charDirection("+"));
// Input data is character type
var_dump(IntlChar::charDirection("."));
// Input data is string type
var_dump(IntlChar::charDirection("ABC"));
// Input data is character type
var_dump(IntlChar::charDirection("c"));
// Input data is character type
var_dump(IntlChar::charDirection("O"));
?>
輸出:
int(0) int(1) int(3) int(6) NULL int(0) int(0)
相關文章:
參考: http://php.net/manual/en/intlchar.chardirection.php
相關用法
- PHP IntlChar::chr()用法及代碼示例
- PHP IntlChar::ord()用法及代碼示例
- PHP IntlChar::ispunct()用法及代碼示例
- PHP IntlChar::isspace()用法及代碼示例
- PHP IntlChar::isWhitespace()用法及代碼示例
- PHP IntlChar::isUUppercase()用法及代碼示例
- PHP IntlChar hasBinaryProperty()用法及代碼示例
- PHP IntlChar::isalnum()用法及代碼示例
- PHP IntlChar::isbase()用法及代碼示例
- PHP IntlChar::islower()用法及代碼示例
- PHP IntlChar::isxdigit()用法及代碼示例
- PHP IntlChar::isprint()用法及代碼示例
- PHP IntlChar::isUAlphabetic()用法及代碼示例
- PHP IntlChar::isULowercase()用法及代碼示例
- PHP IntlChar::isISOControl()用法及代碼示例
注:本文由純淨天空篩選整理自Mahadev99大神的英文原創作品 PHP | IntlChar charDirection() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。