array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.ctype-graph.php', 1 => 'ctype_graph', ), 'up' => array ( 0 => 'ref.ctype.php', 1 => 'Funções da Ctype', ), 'prev' => array ( 0 => 'function.ctype-digit.php', 1 => 'ctype_digit', ), 'next' => array ( 0 => 'function.ctype-lower.php', 1 => 'ctype_lower', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'pt_BR', 'path' => 'reference/ctype/functions/ctype-graph.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
ctype_graph — Verifica se os caracteres são imprimíveis exceto espaço
Verifica se todos os caracteres na string fornecida,
text
, são visíveis.
text
A string a ser testada.
Nota:
Se um int entre -128 e 255 inclusive for fornecido, ele será interpretado como o valor ASCII de um único caractere (valores negativos são somados a 256 para permitir caracteres no intervalo ASCII estendido). Qualquer outro inteiro será interpretado como uma string contendo os dígitos decimais do inteiro.
A partir do PHP 8.1.0, passar um argumento que não seja string tornou-se defasado. No futuro, o argumento será interpretado como uma string em vez de um ponto de código ASCII. Dependendo do comportamento esperado, o argumento deve ser convertido para string ou uma chamada explícita para chr() deve ser feita.
Retorna true
se todos caracteres em text
são
imprimíveis e criam uma saída visível (sem white space), false
caso contrário.
Quando chamada com uma string vazia, o resultado sempre será false
.
Exemplo #1 A ctype_graph() example
<?php
$strings = array('string1' => "asdf\n\r\t", 'string2' => 'arf12', 'string3' => 'LKA#@%.54');
foreach ($strings as $name => $testcase) {
if (ctype_graph($testcase)) {
echo "The string '$name' consists of all (visibly) printable characters.\n";
} else {
echo "The string '$name' does not consist of all (visibly) printable characters.\n";
}
}
?>
O exemplo acima produzirá:
The string 'string1' does not consist of all (visibly) printable characters. The string 'string2' consists of all (visibly) printable characters. The string 'string3' consists of all (visibly) printable characters.