Forum und email

ctype_punct

(PHP 4 >= 4.0.4, PHP 5)

ctype_punct — Verifica se é um caractere imprimível que não é whitespace ou alfanumério

Descrição

bool ctype_punct ( string $text )

Verifica se todos os caracteres da string fornecida, text , são caracteres de pontuação.

Parâmetros

text

A string a ser testada.

Valor Retornado

Retorna TRUE se cada caractere em text é imprimível, não sendo letra, dígito ou espaço em branco, FALSE caso contrário.

Exemplos

Example#1 Um exemplo da ctype_punct()

<?php
$strings 
= array('ABasdk!@!$#''!@ # $''*&$()');
foreach (
$strings as $testcase) {
    if (
ctype_punct($testcase)) {
        echo 
"The string $testcase consists of all punctuation.\n";
    } else {
        echo 
"The string $testcase does not consist of all punctuation.\n";
    }
}
?>

O exemplo acima irá imprimir:

The string ABasdk!@!$# does not consist of all punctuation.
The string !@ # $ does not consist of all punctuation.
The string *&$() consists of all punctuation.