Php-function-ctype-punct

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

PHP-関数ctype_punct()

構文

ctype_punct ( $text );

定義と使い方

この関数は、指定された文字列、テキスト内のすべての文字が句読点文字であるかどうかをチェックします。

パラメーター

Sr.No Parameter & Description
1

text(Required)

テストされた文字列。

戻り値

テキストのすべての文字が印刷可能であればTRUEを返しますが、文字、数字、空白のいずれでもない場合はFALSE、そうでない場合はFALSEを返します。

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

<?php
   $strings = array('k211!@!$#', 'foo!#$bar', '*$()');

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

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

k211!@!$# does not have all punctuation.
foo!#$bar does not have all punctuation.
*$()  consists of all punctuation.