iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 12, 2008
Film Makers, Bands and Comedians Welcome on MySpace
About
 
May 12, 2008
Software Engineering for Ajax
WebReference.com
 
May 12, 2008
What is the Head Tag For?
About
 
May 11, 2008
Improving accessibility for motor impaired users
WebDevTips UK
 
May 11, 2008
10 ways to orientate users on your site
WebDevTips UK
 
May 11, 2008
Web Design Clinic - Rros restoration camp 2006
About
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /PHP

Checking character type 

  Views:    2504
  Votes:    0
by Diego Botello 12/08/03 Rating: 

Synopsis:

Explanation of php functions to directly check character types
Pages: 
The Article

The character type functions are Boolean functions used to check the type of the characters on a string. They return true if all the characters are ofthe type specified by the function. These functions are useful for example if you want to validate a new password submitted by a user. You can check with them that the password submitted do not contains any special character.

The following example shows the use of these functions

 

<?php

$para="There are 10 players on each team.";

print ctype_alnum($para)."<br>"; //returns 1 (true)

print ctype_alpha($para)."<br>"; //returns 0 (false)

$myhex="AF12"

print ctype_xdigit($myhex)."<br>"; //returns 1 (true)

?>

The table bellow list these functions:

Function

Type of characters checked

Example

ctype_alnum

alphanumeric

0-9 A-Z a-z

ctype_alpha

alphabetic

A-Z a-z

ctype_cntrl

control

Tab, esc, etc

ctype_digit

numeric

0-9

ctype_graph

any printable character except space

0-9 A-Z a-z

ctype_lower

lowercase

a-z

ctype_print

printable

0-9 A-Z a-z space

ctype_punct

any printable character which is not whitespace or an alphanumeric character

Nn 0-9 A-Z a-z space

ctype_space

whitespace

blank character , tab, vertical tab, etc.

ctype_upper

uppercase

A-Z

ctype_xdigit

representing a hexadecimal digit

Decimal digits and characters frm A-F and a-f

Pages: 



 
  Sponsors