• PHP Video Tutorials

PHP - Function ctype_punct()



Syntax

ctype_punct ( $text );

Definition and Usage

This function checks if all of the characters in the provided string, text, are punctuation character.

Parameters

Sr.No Parameter & Description
1

text(Required)

The tested string.

Return Value

It returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise.

Example

Try out following example −

<?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";
      }
   }
?> 

This will produce the following result −

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