IntlChar::iscntrl() function in PHP


The IntlChar::iscntrl() function is used to check the given input is a control character or not. Examples include line feed (
), 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("
"));    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

Updated on: 30-Dec-2019

64 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements