reference/strings/functions/addcslashes.xml
45042fef652f1b4e904e809fcbfcf31f6c60670b
45042fef652f1b4e904e809fcbfcf31f6c60670b
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.addcslashes">
3
+
<refentry xml:id="function.addcslashes" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>addcslashes</refname>
6
6
<refpurpose>Quote string with slashes in a C style</refpurpose>
...
...
@@ -10,12 +10,12 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>string</type><methodname>addcslashes</methodname>
13
-
<methodparam><type>string</type><parameter>str</parameter></methodparam>
14
-
<methodparam><type>string</type><parameter>charlist</parameter></methodparam>
13
+
<methodparam><type>string</type><parameter>string</parameter></methodparam>
14
+
<methodparam><type>string</type><parameter>characters</parameter></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
17
Returns a string with backslashes before characters that are
18
-
listed in <parameter>charlist</parameter> parameter.
18
+
listed in <parameter>characters</parameter> parameter.
19
19
</para>
20
20
</refsect1>
21
21
...
...
@@ -24,7 +24,7 @@
24
24
<para>
25
25
<variablelist>
26
26
<varlistentry>
27
-
<term><parameter>str</parameter></term>
27
+
<term><parameter>string</parameter></term>
28
28
<listitem>
29
29
<para>
30
30
The string to be escaped.
...
...
@@ -32,21 +32,22 @@
32
32
</listitem>
33
33
</varlistentry>
34
34
<varlistentry>
35
-
<term><parameter>charlist</parameter></term>
35
+
<term><parameter>characters</parameter></term>
36
36
<listitem>
37
37
<para>
38
38
A list of characters to be escaped. If
39
-
<parameter>charlist</parameter> contains characters
39
+
<parameter>characters</parameter> contains characters
40
40
<literal>\n</literal>, <literal>\r</literal> etc., they are
41
41
converted in C-like style, while other non-alphanumeric characters
42
42
with ASCII codes lower than 32 and higher than 126 converted to
43
43
octal representation.
44
44
</para>
45
45
<para>
46
-
When you define a sequence of characters in the charlist argument
46
+
When you define a sequence of characters in the <parameter>characters</parameter> argument
47
47
make sure that you know what characters come between the
48
48
characters that you set as the start and end of the range.
49
-
<informalexample>
49
+
<example>
50
+
<title><function>addcslashes</function> with Ranges</title>
50
51
<programlisting role="php">
51
52
<![CDATA[
52
53
<?php
...
...
@@ -57,13 +58,14 @@ echo addcslashes('foo[ ]', 'A..z');
57
58
?>
58
59
]]>
59
60
</programlisting>
60
-
</informalexample>
61
+
</example>
61
62
Also, if the first character in a range has a higher ASCII value
62
63
than the second character in the range, no range will be
63
64
constructed. Only the start, end and period characters will be
64
65
escaped. Use the <function>ord</function> function to find the
65
66
ASCII value for a character.
66
-
<informalexample>
67
+
<example>
68
+
<title><function>addcslashes</function> with Characters in Wrong Order</title>
67
69
<programlisting role="php">
68
70
<![CDATA[
69
71
<?php
...
...
@@ -72,7 +74,7 @@ echo addcslashes("zoo['.']", 'z..A');
72
74
?>
73
75
]]>
74
76
</programlisting>
75
-
</informalexample>
77
+
</example>
76
78
</para>
77
79
<para>
78
80
Be careful if you choose to escape characters 0, a, b, f, n, r, t and
...
...
@@ -81,7 +83,7 @@ echo addcslashes("zoo['.']", 'z..A');
81
83
also defined in other C-derived languages, including PHP, meaning that
82
84
you may not get the desired result if you use the output of
83
85
<function>addcslashes</function> to generate code in those languages
84
-
with these characters defined in <parameter>charlist</parameter>.
86
+
with these characters defined in <parameter>characters</parameter>.
85
87
</para>
86
88
</listitem>
87
89
</varlistentry>
...
...
@@ -96,41 +98,19 @@ echo addcslashes("zoo['.']", 'z..A');
96
98
</para>
97
99
</refsect1>
98
100
99
-
<refsect1 role="changelog">
100
-
&reftitle.changelog;
101
-
<para>
102
-
<informaltable>
103
-
<tgroup cols="2">
104
-
<thead>
105
-
<row>
106
-
<entry>&Version;</entry>
107
-
<entry>&Description;</entry>
108
-
</row>
109
-
</thead>
110
-
<tbody>
111
-
<row>
112
-
<entry>5.2.5</entry>
113
-
<entry>
114
-
The escape sequences \v and \f were added.
115
-
</entry>
116
-
</row>
117
-
</tbody>
118
-
</tgroup>
119
-
</informaltable>
120
-
</para>
121
-
</refsect1>
122
-
123
101
<refsect1 role="examples">
124
102
&reftitle.examples;
125
103
<para>
126
-
<parameter>charlist</parameter> like "\0..\37", which would
104
+
<parameter>characters</parameter> like "\0..\37", which would
127
105
escape all characters with ASCII code between 0 and 31.
128
106
<example>
129
107
<title><function>addcslashes</function> example</title>
130
108
<programlisting role="php">
131
109
<![CDATA[
132
110
<?php
111
+
$not_escaped = "PHP isThirty\nYears Old!\tYay to the Elephant!\n";
133
112
$escaped = addcslashes($not_escaped, "\0..\37!@\177..\377");
113
+
echo $escaped;
134
114
?>
135
115
]]>
136
116
</programlisting>
...
...
@@ -152,7 +132,6 @@ $escaped = addcslashes($not_escaped, "\0..\37!@\177..\377");
152
132
</refsect1>
153
133
154
134
</refentry>
155
-
156
135
<!-- Keep this comment at the end of the file
157
136
Local variables:
158
137
mode: sgml
159
138