Php-function-ctype-cntrl

提供:Dev Guides
移動先:案内検索

PHP-関数ctype_cntrl()

構文

ctype_cntrl ( $text );

定義と使い方

指定された文字列、テキスト内のすべての文字が制御文字かどうかをチェックします。 制御文字は、たとえば 改行、タブ、エスケープ。

パラメーター

Sr.No Parameter & Description
1

text(Required)

テストされた文字列。

戻り値

テキスト内のすべての文字が現在のロケールの制御文字である場合はTRUEを返し、そうでない場合はFALSEを返します。

次の例を試してください-

<?php
   $strings = array('\n\r\t', 'example1234r');

   foreach ($strings as $test) {
      if (ctype_cntrl($test)) {
         echo "$test consists of all control characters. \n";
      }else {
         echo "$test does not have all all control characters. \n";
      }
   }
?>

これは、次の結果を生成します-

\n\r\t does not have all all control characters.
example1234r does not have all all control characters.