Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function ctype_punct()


previous

Advertisements

Syntax

ctype_punct ( $text );

Definition and Usage

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

Paramters

ParameterDescription
textRequired. The tested string.

Return Value

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('ABasdk!@!$#', 'foo!#$bar', '*$()');
foreach ($strings as $testcase) {
 if (ctype_punct($testcase)) {
     echo "$testcase consists of all punctuation.<br />";
 } else {
     echo "$testcase does not have all punctuation.<br />";
 }
}
?> 

This will produce following result:

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

previous Printer Friendly

Advertisements


  

Advertisements