language/control-structures/declare.xml
28529d3539b850e870e3aa97570f4db0e53daa03
...
...
@@ -2,7 +2,7 @@
2
2
<!-- $Revision$ -->
3
3

4
4
<sect1 xml:id="control-structures.declare" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
-
<title><literal>declare</literal></title>
5
+
<title>declare</title>
6
6
<?phpdoc print-version-for="declare"?>
7
7
<para>
8
8
The <literal>declare</literal> construct is used to
...
...
@@ -23,37 +23,19 @@ declare (directive)
23
23
The <literal>directive</literal> section allows the
24
24
behavior of the <literal>declare</literal> block to
25
25
be set.
26
-
Currently only two directives are recognized: the
26
+
Currently only three directives are recognized: the
27
27
<literal>ticks</literal> directive (See below for more
28
28
information on the
29
29
<link linkend="control-structures.declare.ticks">ticks</link>
30
-
directive) and the <literal>encoding</literal> directive (See below for more
30
+
directive), the <literal>encoding</literal> directive (See below for more
31
31
information on the
32
32
<link linkend="control-structures.declare.encoding">encoding</link>
33
-
directive).
34
-
</para>
35
-
<para>
36
-
<informaltable>
37
-
<tgroup cols="2">
38
-
<thead>
39
-
<row>
40
-
<entry>&Version;</entry>
41
-
<entry>&Description;</entry>
42
-
</row>
43
-
</thead>
44
-
<tbody>
45
-
<row>
46
-
<entry>5.3.0</entry>
47
-
<entry>Added encoding directive</entry>
48
-
</row>
49
-
<row>
50
-
<entry>7.0.0</entry>
51
-
<entry>Added strict_types directive</entry>
52
-
</row>
53
-
</tbody>
54
-
</tgroup>
55
-
</informaltable>
33
+
directive) and the <literal>strict_types</literal> directive (See for more
34
+
information the
35
+
<link linkend="language.types.declarations.strict">strict typing</link>
36
+
section on the type declarations page)
56
37
</para>
38
+

57
39
<para>
58
40
As directives are handled as the file is being compiled, only literals may
59
41
be given as directive values. Variables and constants cannot be used. To
...
...
@@ -140,42 +122,14 @@ function tick_handler()
140
122
echo "tick_handler() called\n";
141
123
}
142
124

143
-
register_tick_function('tick_handler');
144
-

145
-
$a = 1;
146
-

147
-
if ($a > 0) {
148
-
$a += 2;
149
-
print($a);
150
-
}
151
-

152
-
?>
153
-
]]>
154
-
</programlisting>
155
-
</example>
156
-
</para>
157
-
<para>
158
-
<example>
159
-
<title>Ticks usage example</title>
160
-
<programlisting role="php">
161
-
<![CDATA[
162
-
<?php
163
-

164
-
function tick_handler()
165
-
{
166
-
echo "tick_handler() called\n";
167
-
}
125
+
register_tick_function('tick_handler'); // causes a tick event
168
126

169
-
$a = 1;
170
-
tick_handler();
127
+
$a = 1; // causes a tick event
171
128

172
129
if ($a > 0) {
173
-
$a += 2;
174
-
tick_handler();
175
-
print($a);
176
-
tick_handler();
130
+
$a += 2; // causes a tick event
131
+
print $a; // causes a tick event
177
132
}
178
-
tick_handler();
179
133

180
134
?>
181
135
]]>
...
...
@@ -190,7 +144,7 @@ tick_handler();
190
144
<sect2 xml:id="control-structures.declare.encoding">
191
145
<title>Encoding</title>
192
146
<para>
193
-
A script's encoding can be specified per-script using the encoding directive.
147
+
A script's encoding can be specified per-script using the <literal>encoding</literal> directive.
194
148
<example>
195
149
<title>Declaring an encoding for the script.</title>
196
150
<programlisting role="php">
...
...
@@ -213,14 +167,6 @@ declare(encoding='ISO-8859-1');
213
167
</simpara>
214
168
</caution>
215
169
<para>
216
-
The encoding declare value is ignored in PHP 5.3 unless php is compiled with
217
-
<literal>--enable-zend-multibyte</literal>.
218
-
</para>
219
-
<para>
220
-
Note that PHP does not expose whether <literal>--enable-zend-multibyte</literal> was
221
-
used to compile PHP other than by <function>phpinfo</function>.
222
-
</para>
223
-
<para>
224
170
See also <link linkend="ini.zend.script-encoding">zend.script_encoding</link>.
225
171
</para>
226
172
</sect2>
227
173