Wednesday, November 20, 2024
Google search engine
HomeLanguagesPHP | IntlChar::isdigit() Function

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 )

Parameters: 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: 

php




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


Output: 
 

bool(true)
NULL 
NULL 
NULL

Program 2: 

php




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


Output:  

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

Program 3: 

php




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


Output: 

bool(true) 
bool(false)

References: http://php.net/manual/en/intlchar.isdigit.php

RELATED ARTICLES

Most Popular

Recent Comments