Tutorialspoint.dev

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 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(" "));
  
// Iput 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"));
  
?>

/div>
Output:

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

Program 2:

<?php
// PHP code to illustrate isdefined()
      
// Declare an array $arr
$arr = array("G", "GeeksforGeeks", "^", "1001", "6", " ",
                                             " ", " ");
     
// 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



This article is attributed to GeeksforGeeks.org

You Might Also Like

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter