ctype_punct
(PHP 4 >= 4.0.4, PHP 5)
ctype_punct — Check for any printable character which is not whitespace or an alphanumeric character
Descrierea
$text
)
Checks if all of the characters in the provided string,
text, are punctuation character.
Parametri
-
text -
The tested string.
Valorile întoarse
Returns TRUE if every character in text
is printable, but neither letter, digit or blank, FALSE otherwise.
Exemple
Example #1 A ctype_punct() example
<?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";
}
}
?>
Exemplul de mai sus va afișa:
The string ABasdk!@!$# does not consist of all punctuation. The string !@ # $ does not consist of all punctuation. The string *&$() consists of all punctuation.
Note
Notă:
Dacă e furnizat un integer cu valoarea între -128 și 255 inclusiv, el este interpretat ca o valoare ASCII a unui singur caracter (valorilor negative li se adaugă 256 pentru a permite caractere din domeniul ASCII extins). Orice alt întreg este interpretat ca un string conținând cifrele zecimale ale întregului.
Vedeți de asemenea
- ctype_cntrl() - Check for control character(s)
- ctype_graph() - Check for any printable character(s) except space
