The IntlChar::iscntrl() function is used to check the given input is a control character or not. Examples include line feed (\n), tab (\t), etc.
Syntax
IntlChar::iscntrl( val )
Parameters
val − An integer values or character encoded as a UTF-8 string.
Return
The IntlChar::iscntrl() function returns TRUE if the val is a control character.
Example
The following is an example −
<?php
var_dump(IntlChar::iscntrl("\n"));
echo "<br>";
var_dump(IntlChar::iscntrl("ahjh"));
echo "<br>";
var_dump(IntlChar::iscntrl("12345"));
?>Output
The following is the output −
bool(true) NULL NULL
Example
Let us now see another example wherein we are checking whether the entered value is a control character or not −
<?php
var_dump(IntlChar::iscntrl("\r"));
echo "<br>";
var_dump(IntlChar::iscntrl("878"));
echo "<br>";
?>Output
The following is the output −
bool(true) NULL