Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
PHP Function ctype_punct()
Syntax
Definition and Usage
This function checks if all of the characters in the provided string, text, are punctuation character.
Paramters
Parameter | Description |
text | Required. 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.
|
|
|
|