當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP IntlChar getPropertyValueEnum()用法及代碼示例

IntlChar getPropertyValueEnum() 函數是 PHP 中的一個內置函數,用於從給定值中獲取屬性值。

用法:

int IntlChar::getPropertyValueEnum( $property, $name )

參數:該函數接受上述和以下所述的兩個參數:

  • $property:它存儲 IntlChar::PROPERTY_* 常量。
  • $name:它存儲要存儲的名稱值。

返回值:如果給定的名稱與任何屬性不匹配或屬性無效,則它返回相應的值整數,或 IntlChar::PROPERTY_INVALID_CODE。

以下示例程序旨在說明 PHP 中的 IntlChar::getPropertyValueEnum() 函數:



程序:


<?php
// PHP program to implement IntlChar::getPropertyValueEnum() function
  
// Unicode property constant and it corresponding name is same
var_dump(IntlChar::getPropertyValueEnum(IntlChar::PROPERTY_BIDI_CLASS,
        'RIGHT_TO_LEFT') === IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT);
  
// Unicode property constant and it corresponding name is same
var_dump(IntlChar::getPropertyValueEnum(IntlChar::PROPERTY_BLOCK,
        'greek') === IntlChar::BLOCK_CODE_GREEK);
  
// Unicode property constant and it name is corresponding name is same
var_dump(IntlChar::getPropertyValueEnum(IntlChar::PROPERTY_BIDI_CLASS,
        'some made-up string') === IntlChar::PROPERTY_INVALID_CODE);
  
  
// Unicode property constant and it name is not matching so it return false
var_dump(IntlChar::getPropertyValueEnum(IntlChar::PROPERTY_BIDI_CLASS,
        'RIGHT_TO_LEFT') === IntlChar::BLOCK_CODE_GREEK);
  
?>
輸出:
bool(true)
bool(true)
bool(true)
bool(false)

參考: https://www.php.net/manual/en/intlchar.getpropertyvalueenum.php

相關用法


注:本文由純淨天空篩選整理自snehal98doshi大神的英文原創作品 PHP | IntlChar getPropertyValueEnum() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。