当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。