appendices/migration70/incompatible/variable-handling.xml
35511ebc54edd56f1653a6a956210b4728570316
...
...
@@ -92,6 +92,27 @@
92
92
middle column). This will make the code both forwards compatible with PHP
93
93
7.x and backwards compatible with PHP 5.x.
94
94
</para>
95
+

96
+
<para>
97
+
This also affects the &global; keyword. The curly brace syntax can be
98
+
used to emulate the previous behaviour if required:
99
+
</para>
100
+

101
+
<informalexample>
102
+
<programlisting role="php">
103
+
<![CDATA[
104
+
<?php
105
+
function f() {
106
+
// Valid in PHP 5 only.
107
+
global $$foo->bar;
108
+

109
+
// Valid in PHP 5 and 7.
110
+
global ${$foo->bar};
111
+
}
112
+
?>
113
+
]]>
114
+
</programlisting>
115
+
</informalexample>
95
116
</sect3>
96
117

97
118
<sect3 xml:id="migration70.incompatible.variable-handling.list">
...
...
@@ -232,37 +253,6 @@ array(2) {
232
253
</informalexample>
233
254
</sect3>
234
255

235
-
<sect3 xml:id="migration70.incompatible.variable-handling.global">
236
-
<title>&global; only accepts simple variables</title>
237
-

238
-
<para>
239
-
<link linkend="language.variables.variable">Variable variables</link> can
240
-
no longer be used with the &global; keyword. The curly brace syntax can be
241
-
used to emulate the previous behaviour if required:
242
-
</para>
243
-

244
-
<informalexample>
245
-
<programlisting role="php">
246
-
<![CDATA[
247
-
<?php
248
-
function f() {
249
-
// Valid in PHP 5 only.
250
-
global $$foo->bar;
251
-

252
-
// Valid in PHP 5 and 7.
253
-
global ${$foo->bar};
254
-
}
255
-
?>
256
-
]]>
257
-
</programlisting>
258
-
</informalexample>
259
-

260
-
<para>
261
-
As a general principle, using anything other than a bare variable with
262
-
&global; is discouraged.
263
-
</para>
264
-
</sect3>
265
-

266
256
<sect3 xml:id="migration70.incompatible.variable-handling.parentheses">
267
257
<title>
268
258
Parentheses around function arguments no longer affect behaviour
269
259