PHP | IntlChar::isdigit() Function

The IntlChar::isdigit() function is an inbuilt function in PHP which is used to determine the given input code data is a digited character or not. It returns true when the character is under the general category decimal digit numbers. Beginning with Unicode 4, this is the same as testing for the Numeric_Type of Decimal.

Syntax:

bool IntlChar::isdigit ( $codepoint )

Paramters: This function accepts a single parameter as mentioned above and described below:

  • $codepoint : The input parameter $input_codepoint is an integer or character, which is encoded as a UTF-8 string.

Return Value: If $codepoint data is digit character then return True otherwise return False.

Examples:



Input : $codepoint = "X"
Output : bool(false)

Input : $codepoint = "7"
Output : bool(true)

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

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP code to illustrate the 
// IntlChar::isdigit() function.
  
// single digit
var_dump(IntlChar::isdigit("5"));
  
// number cases
var_dump(IntlChar::isdigit("5555"));
  
// float number
var_dump(IntlChar::isdigit("15.08"));
  
// big number
var_dump(IntlChar::isdigit("12e"));
?>

chevron_right


Output:

bool(true)
NULL 
NULL 
NULL

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP code to illustrate the 
// IntlChar::isdigit() function.
  
// alphabet cases 
var_dump(IntlChar::isdigit("G"));
  
// in space cases
var_dump(IntlChar::isdigit(" "));
  
// new line cases
var_dump(IntlChar::isdigit("\n"));
  
// string cases
var_dump(IntlChar::isdigit("Geeks "));
  
// symbol cases
var_dump(IntlChar::isdigit("@"));
  
?>

chevron_right


Output:

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

Program 3:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP code to illustrate the
// IntlChar::isdigit() function.
  
var_dump(IntlChar::isdigit("0"));
  
var_dump(IntlChar::isdigit(' '));
?>

chevron_right


Output:

bool(true) 
bool(false)

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