PHP | IntlChar getPropertyEnum() Function

The IntlChar::getPropertyEnum() function is an inbuilt function in PHP which is used to get the property constant value for a given property name. The property name is going to be specified in PropertyAliases.txt, which is a Unicode Database file. All types of variants are recognized in this, be it long, short and many others. Additionally, the synthetic names “General_Category_Mask” (abbreviated as “gcm”), is mapped by the function to the IntlChar:: PROPERTY_GENERAL_CATEGORY_MASK property. Also, note that these names that are mentioned here are not going to be present in PropertyAliases.txt. This function gets complimented by IntlChar::getPropertyName() function and vice-versa.

Syntax:

int IntlChar::getPropertyEnum( $alias )

Parameters: This function accepts a single parameter alias whose name of the property that is to be matched. Comparisons for the name are made using the “loose matching”. These are all described in the PropertyAliases.txt.



Return Values: If it is a constant value, it will return an IntlChar::PROPERTY_ value. Otherwise, if the name that is given there, is no matching with any property at all, then IntlChar:: PROPERTY_INVALID_CODE is going to be returned.

Below program illustrates the IntlChar::getPropertyEnum() function in PHP:

Program:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// PHP program to uses IntlChar::getPropertyEnum()
// function
  
// This function uses IntlChar::PROPERTY_* constants
var_dump(IntlChar::getPropertyEnum('Bidi_Class') === IntlChar
                                    ::PROPERTY_NUMERIC_VALUE);
                                      
var_dump(IntlChar::getPropertyEnum('script') === IntlChar
                                    ::PROPERTY_SCRIPT);
                                      
var_dump(IntlChar::getPropertyEnum('IDEOGRAPHIC')=== IntlChar
                ::BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS);
                  
var_dump(IntlChar::getPropertyEnum('Some made-up string') === 
                            IntlChar::PROPERTY_INVALID_CODE);
                              
var_dump(IntlChar::getPropertyEnum('script') === IntlChar
                                    ::PROPERTY_NUMERIC_TYPE);
                                                  
?>

chevron_right


Output:

bool(false)
bool(true)
bool(false)
bool(true)
bool(false)

References: https://www.php.net/manual/en/intlchar.getpropertyenum.php



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.