language/control-structures/declare.xml
5499acf9df7e1338d540bde207acc859792cd139
5499acf9df7e1338d540bde207acc859792cd139
...
...
@@ -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,14 @@ 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
27
-
<literal>ticks</literal> directive (See below for more
28
-
information on the
29
-
<link linkend="control-structures.declare.ticks">ticks</link>
30
-
directive) and the <literal>encoding</literal> directive (See below for more
31
-
information on the
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>
26
+
Currently only three directives are recognized:
27
+
<simplelist>
28
+
<member><link linkend="control-structures.declare.ticks"><literal>ticks</literal></link></member>
29
+
<member><link linkend="control-structures.declare.encoding"><literal>encoding</literal></link></member>
30
+
<member><link linkend="language.types.declarations.strict"><literal>strict_types</literal></link></member>
31
+
</simplelist>
56
32
</para>
33
+
57
34
<para>
58
35
As directives are handled as the file is being compiled, only literals may
59
36
be given as directive values. Variables and constants cannot be used. To
...
...
@@ -140,42 +117,14 @@ function tick_handler()
140
117
echo "tick_handler() called\n";
141
118
}
142
119
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
-
}
120
+
register_tick_function('tick_handler'); // causes a tick event
168
121
169
-
$a = 1;
170
-
tick_handler();
122
+
$a = 1; // causes a tick event
171
123
172
124
if ($a > 0) {
173
-
$a += 2;
174
-
tick_handler();
175
-
print($a);
176
-
tick_handler();
125
+
$a += 2; // causes a tick event
126
+
print $a; // causes a tick event
177
127
}
178
-
tick_handler();
179
128
180
129
?>
181
130
]]>
...
...
@@ -190,9 +139,9 @@ tick_handler();
190
139
<sect2 xml:id="control-structures.declare.encoding">
191
140
<title>Encoding</title>
192
141
<para>
193
-
A script's encoding can be specified per-script using the encoding directive.
142
+
A script's encoding can be specified per-script using the <literal>encoding</literal> directive.
194
143
<example>
195
-
<title>Declaring an encoding for the script.</title>
144
+
<title>Declaring an encoding for the script</title>
196
145
<programlisting role="php">
197
146
<![CDATA[
198
147
<?php
...
...
@@ -212,14 +161,6 @@ declare(encoding='ISO-8859-1');
212
161
will result in a parse error when combined with namespaces.
213
162
</simpara>
214
163
</caution>
215
-
<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
164
<para>
224
165
See also <link linkend="ini.zend.script-encoding">zend.script_encoding</link>.
225
166
</para>
226
167