Open In App

PHP | IntlChar getPropertyEnum() Function

Last Updated : 27 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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:




<?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);
                                                  
?>


Output:

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

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads