ctype_alnum> <Constantes pré-definidas
Last updated: Fri, 03 Feb 2012

Funções da Ctype

Índice

  • ctype_alnum — Verifica se os caracteres são alfanuméricos
  • ctype_alpha — Verifica se os caracteres são alfabéticos
  • ctype_cntrl — Verifica se os caracteres são de controle
  • ctype_digit — Verifica se os caracteres são numéricos
  • ctype_graph — Verifica se os caracteres são imprimíveis exceto espaço
  • ctype_lower — Verifica se os caracteres estão minúsculos
  • ctype_print — Verifica se os caracteres são imprimíveis
  • ctype_punct — Verifica se é um caractere imprimível que não é whitespace ou alfanumério
  • ctype_space — Verifica se os caracteres são whitespace
  • ctype_upper — Verifica se os caracteres são maiúsculos
  • ctype_xdigit — Verifica se os caracteres representam um dígito hexadecimal


ctype_alnum> <Constantes pré-definidas
Last updated: Fri, 03 Feb 2012
 
User Contributed Notes
Funções da Ctype
jerome at yazo dot net
15-Mar-2009 01:18
worth noticing? It seems that the ctype_alpha family of functions won't handle UTF-8 string (php 5.2.6)

<?php

$texte
= 'jérôme';
setLocale(LC_CTYPE, 'FR_fr');
echo
'Pure ascii ? ', (ctype_alpha($texte) ) ? 'yes' : 'no';
echo
'<br />';
$texte = iconv( "UTF-8", "ISO-8859-1", $texte) ;
echo 
'Letters only ? ' , (ctype_alpha($texte) ) ? 'yes' : 'no';

?>

ouputs :

Pure ascii ? no
Letters only ? yes
14-Oct-2006 11:44
In PHP versions before 4.4.1, ctype functions have a bug handling very large integers.
http://bugs.php.net/bug.php?id=34645
See Crimson's comment under ctype_digit, or this test code from the bug:
<?php
$id
= 394829384;
var_dump($id);
ctype_digit($id);
var_dump($id);
?>

Expected result:
----------------
int(394829384)
int(394829384)

Actual result:
--------------
int(394829384)
NULL

The fix is to cast it as a string:
<?php
ctype_digit
((string)$id);
?>
... or use a current version of PHP!
avarab at gmail dot com
03-Jan-2006 06:58
In case the ctype_*() functions aren't compiled in your PHP and you can't recompile for some reason (e.g. shared host) you can use the compatability functions from the MediaWiki project which use preg_* as a replacement[1], removing lines 2 and 3 in the source should make them suitable for usage elsewhere.

Shameless self-advertisement, but hey, we find them useful;)

1. A tinyurl because the submission script complained about long lines: http://tinyurl.com/7hz4l
1. The real url split up:
http://cvs.sourceforge.net/viewcvs.py/*checkout*/
wikipedia/phase3/includes/compatability/ctype.php

ctype_alnum> <Constantes pré-definidas
Last updated: Fri, 03 Feb 2012