reference/array/functions/compact.xml
e311803cd2fb931ad80bab6fd0f996d2ece6e2b8
...
...
@@ -9,8 +9,8 @@
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
11
<type>array</type><methodname>compact</methodname>
12
-
<methodparam><type>mixed</type><parameter>varname1</parameter></methodparam>
13
-
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
12
+
<methodparam><type class="union"><type>array</type><type>string</type></type><parameter>var_name</parameter></methodparam>
13
+
<methodparam rep="repeat"><type class="union"><type>array</type><type>string</type></type><parameter>var_names</parameter></methodparam>
14
14
</methodsynopsis>
15
15
<para>
16
16
Creates an array containing variables and their values.
...
...
@@ -22,16 +22,19 @@
22
22
and the contents of the variable become the value for that key.
23
23
In short, it does the opposite of <function>extract</function>.
24
24
</para>
25
-
<para>
26
-
Any strings that are not set will simply be skipped.
27
-
</para>
25
+
<note>
26
+
<para>
27
+
Before PHP 7.3, any strings that are not set will silently be skipped.
28
+
</para>
29
+
</note>
28
30
</refsect1>
29
31
<refsect1 role="parameters">
30
32
&reftitle.parameters;
31
33
<para>
32
34
<variablelist>
33
35
<varlistentry>
34
-
<term><parameter>varname1</parameter></term>
36
+
<term><parameter>var_name</parameter></term>
37
+
<term><parameter>var_names</parameter></term>
35
38
<listitem>
36
39
<para>
37
40
<function>compact</function> takes a variable number of parameters.
...
...
@@ -51,6 +54,44 @@
51
54
Returns the output array with all the variables added to it.
52
55
</para>
53
56
</refsect1>
57
+

58
+
<refsect1 role="errors">
59
+
&reftitle.errors;
60
+
<para>
61
+
<function>compact</function> issues an <constant>E_WARNING</constant> level error if a given string
62
+
refers to an unset variable.
63
+
</para>
64
+
</refsect1>
65
+

66
+
<refsect1 role="changelog"><!-- {{{ -->
67
+
&reftitle.changelog;
68
+
<informaltable>
69
+
<tgroup cols="2">
70
+
<thead>
71
+
<row>
72
+
<entry>&Version;</entry>
73
+
<entry>&Description;</entry>
74
+
</row>
75
+
</thead>
76
+
<tbody>
77
+
<row>
78
+
<entry>8.0.0</entry>
79
+
<entry>
80
+
If a given string references an unset variable, an <constant>E_WARNING</constant> level error is now issued.
81
+
</entry>
82
+
</row>
83
+
<row>
84
+
<entry>7.3.0</entry>
85
+
<entry>
86
+
<function>compact</function> now issues an <constant>E_NOTICE</constant> level error if a given string
87
+
refers to an unset variable. Formerly, such strings have been silently skipped.
88
+
</entry>
89
+
</row>
90
+
</tbody>
91
+
</tgroup>
92
+
</informaltable>
93
+
</refsect1><!-- }}} -->
94
+

54
95
<refsect1 role="examples">
55
96
&reftitle.examples;
56
97
<para>
...
...
@@ -65,7 +106,7 @@ $event = "SIGGRAPH";
65
106

66
107
$location_vars = array("city", "state");
67
108

68
-
$result = compact("event", "nothing_here", $location_vars);
109
+
$result = compact("event", $location_vars);
69
110
print_r($result);
70
111
?>
71
112
]]>
...
...
@@ -106,7 +147,6 @@ Array
106
147
</para>
107
148
</refsect1>
108
149
</refentry>
109
-

110
150
<!-- Keep this comment at the end of the file
111
151
Local variables:
112
152
mode: sgml
113
153