Open In App
Related Articles

PHP | IntlChar isdefined() Function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
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:
<?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"));
  
?>

                    
Output:
bool(true)
bool(true)
bool(false)
NULL
bool(true)
Program 2:
<?php
// PHP code to illustrate IntlChar::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));
}
?>

                    
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

Last Updated : 03 Nov, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads