PHP | IntlChar getIntPropertyValue() Function

The IntlChar::getIntPropertyValue() function is an inbuilt function in PHP which is used to get the value for Unicode property for a code point.

Syntax:

int IntlChar::getIntPropertyValue( $codepoint, $property )

Parameter: This function accepts two parameters as mentioned above and described below:

  • $codepoint: The input parameter $codepoint is a character or interger value, which is encoded as a UTF-8 string.
  • $property It store the unicode character constant. Example: IntlChar::PROPERTY_* constants.

Return Values:

  • It returns the numeric value which is directly the property value or, enumerated properties, corresponds to the numeric value of the enumerated constant of the respective property value enumeration type.
  • It returns the boolean value (0/1 or FALSE/TRUE) for binary Unicode properties.
  • It returns the bit-mask value for mask properties.
  • It returns 0 if the property is out of bounds or if the Unicode version does not have data for the property at all, or not for this code point.

Below programs illustrate the IntlChar::getIntPropertyValue() function in PHP:



Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Input data is alphabet character type
var_dump(IntlChar::getIntPropertyValue("A",
        IntlChar::PROPERTY_ALPHABETIC) === 1);
  
// Input data is mirrored brackets character type
var_dump(IntlChar::getIntPropertyValue("["
        IntlChar::PROPERTY_BIDI_MIRRORED) === 1);
  
// Input data is Space character type
var_dump(IntlChar::getIntPropertyValue(" "
        IntlChar::PROPERTY_POSIX_BLANK) === 1);
  
// Input data is special character type
var_dump(IntlChar::getIntPropertyValue("?"
    IntlChar::PROPERTY_BLOCK) === IntlChar::BLOCK_CODE_GREEK);
  
?>

chevron_right


Output:

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

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Input data is alphabet character type
var_dump(IntlChar::getIntPropertyValue("A"
        IntlChar::PROPERTY_ALPHABETIC) === 1);
  
// Input data is special character type
var_dump(IntlChar::getIntPropertyValue("|"
        IntlChar::PROPERTY_BIDI_MIRRORED) === 1);
  
// Input data is special character type
var_dump(IntlChar::getIntPropertyValue("?"
    IntlChar::PROPERTY_BLOCK) === IntlChar::BLOCK_CODE_GREEK);
  
// Input data is numeric character type
var_dump(IntlChar::getIntPropertyValue("9",
        IntlChar::PROPERTY_NUMERIC_TYPE) === 1 );
  
// Input data is math character type
var_dump(IntlChar::getIntPropertyValue("=",
        IntlChar::PROPERTY_MATH) === 1 );
  
?>

chevron_right


Output:

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

Reference: https://www.php.net/manual/en/intlchar.getintpropertyvalue.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.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.