<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Character Type Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="函数参考" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="crack_opendict" HREF="function.crack-opendict.html"><LINK REL="NEXT" TITLE="ctype_alnum" HREF="function.ctype-alnum.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.crack-opendict.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ctype-alnum.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.ctype" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XVII. Character Type Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN23693" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ctype.intro" >简介</A ></H1 ><P > The functions provided by this extension check whether a character or string falls into a certain character class according to the current locale (see also <A HREF="function.setlocale.html" ><B CLASS="function" >setlocale()</B ></A >). </P ><P > When called with an integer argument these functions behave exactly like their C counterparts from <TT CLASS="filename" >ctype.h</TT >. It means that if you pass an integer smaller than 256 it will use the ASCII value of it to see if it fits in the specified range (digits are in 0x30-0x39). If the number is between -128 and -1 inclusive then 256 will be added and the check will be done on that. </P ><P > When called with a string argument they will check every character in the string and will only return <TT CLASS="constant" ><B >TRUE</B ></TT > if every character in the string matches the requested criteria. When called with an empty string the result will always be <TT CLASS="constant" ><B >TRUE</B ></TT > in PHP < 5.1 and <TT CLASS="constant" ><B >FALSE</B ></TT > since 5.1. </P ><P > Passing anything else but a string or integer will return <TT CLASS="constant" ><B >FALSE</B ></TT > immediately. </P ><P > It should be noted that ctype functions are always preferred over regular expressions, and even to some equivalent str_* and is_* functions. This is because of the fact that ctype uses a native C library and thus processes significantly faster. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ctype.requirements" >需求</A ></H1 ><P > None besides functions from the standard C library which are always available. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ctype.installation" >安装</A ></H1 ><P > Beginning with PHP 4.2.0 these functions are enabled by default. For older versions you have to configure and compile PHP with <CODE CLASS="option" >--enable-ctype</CODE >. You can disable ctype support with <CODE CLASS="option" >--disable-ctype</CODE >. </P ><P > <TT CLASS="literal" >PHP</TT > 的 Windows 版本已经内置该扩展模块的支持。无需加载任何附加扩展库即可使用这些函数。</P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </B > Builtin support for ctype is available with PHP 4.3.0. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ctype.configuration" >运行时配置</A ></H1 ><P >本扩展模块在 <TT CLASS="filename" >php.ini</TT > 中未定义任何配置选项。</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ctype.resources" >资源类型</A ></H1 ><P >本扩展模块未定义任何资源类型。</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ctype.constants" >预定义常量</A ></H1 ><P >本扩展模块未定义任何常量。</P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >目录</B ></DT ><DT ><A HREF="function.ctype-alnum.html" >ctype_alnum</A > -- Check for alphanumeric character(s)</DT ><DT ><A HREF="function.ctype-alpha.html" >ctype_alpha</A > -- Check for alphabetic character(s)</DT ><DT ><A HREF="function.ctype-cntrl.html" >ctype_cntrl</A > -- Check for control character(s)</DT ><DT ><A HREF="function.ctype-digit.html" >ctype_digit</A > -- Check for numeric character(s)</DT ><DT ><A HREF="function.ctype-graph.html" >ctype_graph</A > -- Check for any printable character(s) except space</DT ><DT ><A HREF="function.ctype-lower.html" >ctype_lower</A > -- Check for lowercase character(s)</DT ><DT ><A HREF="function.ctype-print.html" >ctype_print</A > -- Check for printable character(s)</DT ><DT ><A HREF="function.ctype-punct.html" >ctype_punct</A > -- Check for any printable character which is not whitespace or an alphanumeric character </DT ><DT ><A HREF="function.ctype-space.html" >ctype_space</A > -- Check for whitespace character(s)</DT ><DT ><A HREF="function.ctype-upper.html" >ctype_upper</A > -- Check for uppercase character(s)</DT ><DT ><A HREF="function.ctype-xdigit.html" >ctype_xdigit</A > -- Check for character(s) representing a hexadecimal digit </DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.crack-opendict.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ctype-alnum.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >crack_opendict</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ctype_alnum</TD ></TR ></TABLE ></DIV ></BODY ></HTML >