reference/funchand/functions/call-user-func.xml
2eb43ad4f41a8c62516abd804721786e50717af6
...
...
@@ -11,8 +11,7 @@
11
11
<methodsynopsis>
12
12
<type>mixed</type><methodname>call_user_func</methodname>
13
13
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
14
-
<methodparam choice="opt"><type>mixed</type><parameter>parameter</parameter></methodparam>
15
-
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
14
+
<methodparam rep="repeat"><type>mixed</type><parameter>args</parameter></methodparam>
16
15
</methodsynopsis>
17
16
<para>
18
17
Calls the <parameter>callback</parameter> given by the first parameter and passes
...
...
@@ -33,7 +32,7 @@
33
32
</listitem>
34
33
</varlistentry>
35
34
<varlistentry>
36
-
<term><parameter>parameter</parameter></term>
35
+
<term><parameter>args</parameter></term>
37
36
<listitem>
38
37
<para>
39
38
Zero or more parameters to be passed to the callback.
...
...
@@ -57,17 +56,24 @@ $a = 0;
57
56
call_user_func('increment', $a);
58
57
echo $a."\n";
59
58

60
-
// You can use this instead
59
+
// it is possible to use this instead
61
60
call_user_func_array('increment', array(&$a));
62
61
echo $a."\n";
62
+

63
+
// it is also possible to use a variable function
64
+
$increment = 'increment';
65
+
$increment($a);
66
+
echo $a."\n";
63
67
?>
64
68
]]>
65
69
</programlisting>
66
70
&example.outputs;
67
71
<screen>
68
72
<![CDATA[
73
+
Warning: Parameter 1 to increment() expected to be a reference, value given in …
69
74
0
70
75
1
76
+
2
71
77
]]>
72
78
</screen>
73
79
</example>
...
...
@@ -86,33 +92,6 @@ echo $a."\n";
86
92
</para>
87
93
</refsect1>
88
94

89
-
<refsect1 role="changelog">
90
-
&reftitle.changelog;
91
-
<para>
92
-
<informaltable>
93
-
<tgroup cols="2">
94
-
<thead>
95
-
<row>
96
-
<entry>&Version;</entry>
97
-
<entry>&Description;</entry>
98
-
</row>
99
-
</thead>
100
-
<tbody>
101
-
<row>
102
-
<entry>5.3.0</entry>
103
-
<entry>
104
-
The interpretation of object oriented keywords like <literal>parent</literal>
105
-
and <literal>self</literal> has changed. Previously, calling them using the
106
-
double colon syntax would emit an <constant>E_STRICT</constant> warning because
107
-
they were interpreted as static.
108
-
</entry>
109
-
</row>
110
-
</tbody>
111
-
</tgroup>
112
-
</informaltable>
113
-
</para>
114
-
</refsect1>
115
-

116
95
<refsect1 role="examples">
117
96
&reftitle.examples;
118
97
<para>
...
...
@@ -152,8 +131,8 @@ class Foo {
152
131
}
153
132
}
154
133

155
-
call_user_func(__NAMESPACE__ .'\Foo::test'); // As of PHP 5.3.0
156
-
call_user_func(array(__NAMESPACE__ .'\Foo', 'test')); // As of PHP 5.3.0
134
+
call_user_func(__NAMESPACE__ .'\Foo::test');
135
+
call_user_func(array(__NAMESPACE__ .'\Foo', 'test'));
157
136

158
137
?>
159
138
]]>
...
...
@@ -182,7 +161,7 @@ class myclass {
182
161
$classname = "myclass";
183
162

184
163
call_user_func(array($classname, 'say_hello'));
185
-
call_user_func($classname .'::say_hello'); // As of 5.2.3
164
+
call_user_func($classname .'::say_hello');
186
165

187
166
$myobject = new myclass();
188
167

...
...
@@ -205,7 +184,7 @@ Hello!
205
184
<programlisting role="php">
206
185
<![CDATA[
207
186
<?php
208
-
call_user_func(function($arg) { print "[$arg]\n"; }, 'test'); /* As of PHP 5.3.0 */
187
+
call_user_func(function($arg) { print "[$arg]\n"; }, 'test');
209
188
?>
210
189
]]>
211
190
</programlisting>
...
...
@@ -230,7 +209,7 @@ call_user_func(function($arg) { print "[$arg]\n"; }, 'test'); /* As of PHP 5.3.0
230
209
<simplelist>
231
210
<member><function>call_user_func_array</function></member>
232
211
<member><function>is_callable</function></member>
233
-
<member>&seealso.callback;</member>
212
+
<member><link linkend="functions.variable-functions">Variable functions</link></member>
234
213
<member><methodname>ReflectionFunction::invoke</methodname></member>
235
214
<member><methodname>ReflectionMethod::invoke</methodname></member>
236
215
</simplelist>
237
216