-
Notifications
You must be signed in to change notification settings - Fork 102
/
book.xml
77 lines (72 loc) · 2.65 KB
/
book.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 1af58f6311e4884398f334e8dd7c5ac5131988ba Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<book xml:id="book.ctype" xmlns="http://docbook.org/ns/docbook">
<?phpdoc extension-membership="bundled" ?>
<title>字符类型检测</title>
<titleabbrev>Ctype</titleabbrev>
<preface xml:id="intro.ctype">
&reftitle.intro;
<para>
该扩展所提供的函数用来检测
在当前的区域设定下(参见 <function>setlocale</function>)检查字符或者字符串
是否仅包含指定类型的字符。
</para>
<para>
当使用整数作为参数调用这些函数的时候,
这些函数的行为和 C 语言(<filename>ctype.h</filename>)
中的对应函数一样。
也就是说,如果传入了小于 256 的整数参数,它会把这个整数当做 ASCII 码值,
来检测对应字符是否符合要求(数值检测的 ASCII 值范围为 0x30-0x39)。
如果传入的参数介于 -128 和 -1 之间(含 -128 和 -1),它会先将其加上 256,然后再进行检测。
</para>
¬e.ctype.parameter.non-string;
<para>
当传入参数为字符串的时候,它会对字符串中的每个字符进行检测,
仅当字符串中的每个字符都符合指定条件的情况下才会返回 &true;。
&ctype.result.empty-string;
</para>
<para>
传入除整数和字符串之外的参数
会立即返回 &false;。
</para>
<para>
需要提醒的是,如果可以满足需求,请优先考虑使用 ctype 函数,
而不是正则表达式或者对应的 <literal>"str_*"</literal> 和 <literal>"is_*"</literal> 函数。
因为 ctype 使用的是原生 C 库,所以会有明显的性能优势。
</para>
<note>
<para>
这些函数和 Python 中的 “ctypes” 库没有任何关系。
ctype 的名字源自对应的 C 语言中的头文件 <filename>ctype.h</filename>。
</para>
<para>
实际上,这个扩展是先于 Python 的 “ctypes”,所以该命名引起的任何困扰都不是 PHP 的错。
</para>
</note>
</preface>
&reference.ctype.setup;
&reference.ctype.constants;
&reference.ctype.reference;
</book>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->