PHP | IntlChar isdefined() Function

The IntlChar::isdefined() function is an inbuilt function in PHP which is used to check whether the code point is defined or not. The character is said to be determined if it is assigned a character. It is True for general categories other than Cn (other, not assigned).

Syntax:

bool IntlChar::isdefined ( $codepoint )

Parameters: This function accepts a single parameter $codepoint which is mandatory. The $codepoint value is an integer values or character, which is encoded as a UTF-8 string.



Return Value: This function returns True if $codepoint is a defined character, False otherwise.

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

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// PHP function to illustrate 
// the use of IntlChar::isdefined()
  
// Input data is character type
var_dump(IntlChar::isdefined("A"));
  
// Input data is character type
var_dump(IntlChar::isdefined(" "));
  
// Input data is unicode character
var_dump(IntlChar::isdefined("\u{FDD0}"));
  
// Input data is string type
var_dump(IntlChar::isdefined("XYZ"));
  
// Input data is character type
var_dump(IntlChar::isdefined("5"));
  
?>

chevron_right


Output:

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

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP code to illustrate isdefined()
      
// Declare an array $arr
$arr = array("G", "GeeksforGeeks", "^", "1001", "6", "\n",
                                             "\n\n", "\t");
     
// Loop run for every array element
foreach ($arr as $val){
         
    // Check each element as code point data
    var_dump(IntlChar::isdefined($val));
}
?>

chevron_right


Output:

bool(true)
NULL
bool(true)
NULL
bool(true)
bool(true)
NULL
bool(true)

Related Articles:

Reference: http://php.net/manual/en/intlchar.isdefined.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.