reference/funchand/functions/func-get-arg.xml
de42b5016e8d9cbfd245d70f65354a86f4e2f031
...
...
@@ -1,4 +1,4 @@
1
-
<?xml version="1.0" encoding="iso-8859-1"?>
1
+
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3
<refentry xml:id="function.func-get-arg" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
...
...
@@ -10,7 +10,7 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>mixed</type><methodname>func_get_arg</methodname>
13
-
<methodparam><type>int</type><parameter>arg_num</parameter></methodparam>
13
+
<methodparam><type>int</type><parameter>position</parameter></methodparam>
14
14
</methodsynopsis>
15
15
<para>
16
16
Gets the specified argument from a user-defined function's argument list.
...
...
@@ -27,7 +27,7 @@
27
27
<para>
28
28
<variablelist>
29
29
<varlistentry>
30
-
<term><parameter>arg_num</parameter></term>
30
+
<term><parameter>position</parameter></term>
31
31
<listitem>
32
32
<para>
33
33
The argument offset. Function arguments are counted starting from
...
...
@@ -46,35 +46,11 @@
46
46
</para>
47
47
</refsect1>
48
48

49
-
<refsect1 role="changelog">
50
-
&reftitle.changelog;
51
-
<para>
52
-
<informaltable>
53
-
<tgroup cols="2">
54
-
<thead>
55
-
<row>
56
-
<entry>&Version;</entry>
57
-
<entry>&Description;</entry>
58
-
</row>
59
-
</thead>
60
-
<tbody>
61
-
<row>
62
-
<entry>5.3.0</entry>
63
-
<entry>
64
-
This function can now be used in parameter lists.
65
-
</entry>
66
-
</row>
67
-
</tbody>
68
-
</tgroup>
69
-
</informaltable>
70
-
</para>
71
-
</refsect1>
72
-

73
49
<refsect1 role="errors">
74
50
&reftitle.errors;
75
51
<para>
76
52
Generates a warning if called from outside of a user-defined function, or
77
-
if <parameter>arg_num</parameter> is greater than the number of arguments
53
+
if <parameter>position</parameter> is greater than the number of arguments
78
54
actually passed.
79
55
</para>
80
56
</refsect1>
...
...
@@ -90,23 +66,66 @@
90
66
function foo()
91
67
{
92
68
$numargs = func_num_args();
93
-
echo "Number of arguments: $numargs<br />\n";
69
+
echo "Number of arguments: $numargs\n";
94
70
if ($numargs >= 2) {
95
-
echo "Second argument is: " . func_get_arg(1) . "<br />\n";
71
+
echo "Second argument is: " . func_get_arg(1) . "\n";
96
72
}
97
73
}
98
74

99
-
foo (1, 2, 3);
75
+
foo(1, 2, 3);
100
76
?>
101
77
]]>
102
78
</programlisting>
79
+
&example.outputs;
80
+
<screen>
81
+
<![CDATA[
82
+
Number of arguments: 3
83
+
Second argument is: 2
84
+
]]>
85
+
</screen>
103
86
</example>
104
87
</para>
88
+

89
+
<para>
90
+
<example>
91
+
<title><function>func_get_arg</function> example of byref and byval arguments</title>
92
+
<programlisting role="php">
93
+
<![CDATA[
94
+
<?php
95
+
function byVal($arg) {
96
+
echo 'As passed : ', var_export(func_get_arg(0)), PHP_EOL;
97
+
$arg = 'baz';
98
+
echo 'After change : ', var_export(func_get_arg(0)), PHP_EOL;
99
+
}
100
+

101
+
function byRef(&$arg) {
102
+
echo 'As passed : ', var_export(func_get_arg(0)), PHP_EOL;
103
+
$arg = 'baz';
104
+
echo 'After change : ', var_export(func_get_arg(0)), PHP_EOL;
105
+
}
106
+

107
+
$arg = 'bar';
108
+
byVal($arg);
109
+
byRef($arg);
110
+
?>
111
+
]]>
112
+
</programlisting>
113
+
&example.outputs;
114
+
<screen>
115
+
As passed : 'bar'
116
+
After change : 'baz'
117
+
As passed : 'bar'
118
+
After change : 'baz'
119
+
</screen>
120
+
</example>
121
+
</para>
122
+

105
123
</refsect1>
106
124

107
125
<refsect1 role="notes">
108
126
&reftitle.notes;
109
-
&note.funcnoparam;
127
+
&note.func-named-params;
128
+
&note.funcbyref;
110
129
<note>
111
130
<simpara>
112
131
This function returns a copy of the passed arguments only, and does not
...
...
@@ -119,6 +138,7 @@ foo (1, 2, 3);
119
138
&reftitle.seealso;
120
139
<para>
121
140
<simplelist>
141
+
<member><link linkend="functions.variable-arg-list"><literal>...</literal> syntax</link></member>
122
142
<member><function>func_get_args</function></member>
123
143
<member><function>func_num_args</function></member>
124
144
</simplelist>
...
...
@@ -126,7 +146,6 @@ foo (1, 2, 3);
126
146
</refsect1>
127
147

128
148
</refentry>
129
-

130
149
<!-- Keep this comment at the end of the file
131
150
Local variables:
132
151
mode: sgml
...
...
@@ -138,7 +157,7 @@ sgml-indent-step:1
138
157
sgml-indent-data:t
139
158
indent-tabs-mode:nil
140
159
sgml-parent-document:nil
141
-
sgml-default-dtd-file:"../../../../manual.ced"
160
+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
142
161
sgml-exposed-tags:nil
143
162
sgml-local-catalogs:nil
144
163
sgml-local-ecat-files:nil
145
164