English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
A função ctype_graph() verifica strings impressíveis, exceto espaços
ctype_graph(\$text);
Verifica se todos os caracteres de text fornecido são visíveis.
Número | Parâmetros e descrição |
---|---|
1 | text (obrigatório) String a ser testada. |
Se todos os caracteres do texto forem impressíveis e realmente criarem uma saída visível (sem espaços), retornará TRUE, caso contrário, retornará FALSE.
<?php \$strings = array('string1' => "asdf\n\r\t", 'string2' => 'arf12', 'string3' => 'LKA#@%.54'); foreach (\$strings as \$test) { if (ctype_graph(\$test)) { echo "\$test é composto por caracteres visíveis e imprimíveis \n"; }else { echo "\$test contém caracteres invisíveis.\n"; } } ?>Teste e veja‹/›
Resultado da saída:
asdf Contém caracteres invisíveis. arf12 Composta por caracteres visíveis e imprimíveis LKA#@%.54 Composta por caracteres visíveis e imprimíveis