PHP - Fonction ctype_punct ()
Syntaxe
ctype_punct ( $text );
Définition et utilisation
Cette fonction vérifie si tous les caractères de la chaîne fournie, texte, sont des caractères de ponctuation.
Paramètres
| Sr.Non | Paramètre et description |
|---|---|
| 1 | text(Required) La chaîne testée. |
Valeur de retour
Il renvoie TRUE si chaque caractère du texte est imprimable, mais ni lettre, ni chiffre, ni blanc, FALSE sinon.
Exemple
Essayez l'exemple suivant -
<?php
$strings = array('[email protected]!$#', '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";
}
}
?>
Cela produira le résultat suivant -
[email protected]!$# does not have all punctuation.
foo!#$bar does not have all punctuation.
*$() consists of all punctuation.
