Open In App

PHP | IntlChar::isJavaSpaceChar() Function

Last Updated : 23 Apr, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The IntlChar::isJavaSpaceChar() function is an inbuilt function in PHP which is used to check whether the input character code point is a space character or not according to Java. Its value is True for characters with general category “Z” (Separators), which does not include control character.
Syntax: 
 

bool IntlChar::isJavaSpaceChar( $codepoint )

Parameters: This function accepts a single parameter $codepoint which is mandatory. The input parameter $codepoint is a character or integer value, which is encoded as a UTF-8 string.
Return Value: Returns True, if $codepoint is space character according to java, otherwise return False.
Below programs illustrate the IntlChar::isJavaSpaceChar() Function in PHP:
Program 1: 
 

php




<?php
// PHP function to illustrate the
// use of IntlChar::isJavaSpaceChar()
 
// Input control character codepoint value
var_dump(IntlChar::isJavaSpaceChar("\n"));
 
// Input control character codepoint value
var_dump(IntlChar::isJavaSpaceChar("\r"));
 
// Input string codepoint value with
// Capital and small letter
var_dump(IntlChar::isJavaSpaceChar("V"));
 
// Input int char an identifier
// of codepoint value
var_dump(IntlChar::isJavaSpaceChar("\u{00A0}"));
  
// Input symbolic space codepoint value
var_dump(IntlChar::isJavaSpaceChar(" "));
 
// Input symbolic codepoint value
var_dump(IntlChar::isJavaSpaceChar(" ^ "));
 
// Input string codepoint value
var_dump(IntlChar::isJavaSpaceChar("Bug"));
    
// Input int codepoint value
var_dump(IntlChar::isJavaSpaceChar("3 "));
  
?>


Output: 
 

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

Program 2: 
 

php




<?php
// PHP function to illustrate the
// use of IntlChar::isJavaSpaceChar()
  
// Declare an array with
// different codepoint value
$arr = array("\\",
             " ",
             "\n",
             " #",
             "\t",
        );
    
// For loop condition to check
// each character through function
foreach ($arr as $val) {
        
    // Check each element as code point data
    var_dump(IntlChar::isJavaSpaceChar($val));
}
?>


Output: 
 

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

Related Articles: 
 

Reference: http://php.net/manual/en/intlchar.isjavaspacechar.php
 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads