-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathmax.xml
More file actions
200 lines (189 loc) · 6.15 KB
/
max.xml
File metadata and controls
200 lines (189 loc) · 6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 761d72245071f89a626903c9bcdc6aaff1252d54 Maintainer: PhilDaiguille Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.max" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>max</refname>
<refpurpose>El valor más grande</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>mixed</type><methodname>max</methodname>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
<methodparam rep="repeat"><type>mixed</type><parameter>values</parameter></methodparam>
</methodsynopsis>
<simpara>Firma alternativa (no soportada con argumentos nombrados):</simpara>
<methodsynopsis>
<type>mixed</type><methodname>max</methodname>
<methodparam><type>array</type><parameter>value_array</parameter></methodparam>
</methodsynopsis>
<para>
Si el primer y único parámetro es un array, <function>max</function>
devuelve el valor más alto del array. Si se proporcionan al menos dos parámetros,
<function>max</function> devuelve el más grande de estos valores.
</para>
<note>
<para>
Los valores de diferentes tipos serán comparados utilizando
las <link linkend="language.operators.comparison">reglas de
comparación estándar</link>. Actualmente, un string no numérico
será comparado con un &integer; como si fuera el valor
<literal>0</literal>, pero varios &string; no numéricos serán comparados de forma
alfanumérica. El valor actual devuelto será del mismo tipo que el original y no se aplicará ninguna conversión de tipo.
</para>
</note>
<caution>
<simpara>
Tenga cuidado al pasar argumentos con tipos diferentes,
ya que <function>max</function> puede producir resultados impredecibles.
</simpara>
</caution>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
Cualquier valor <link linkend="language.operators.comparison">comparable</link>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>values</parameter></term>
<listitem>
<para>
Cualquier valor <link linkend="language.operators.comparison">comparable</link>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>value_array</parameter></term>
<listitem>
<para>
Un array que contiene los valores.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
La función <function>max</function> devuelve el valor del parámetro
considerado como "superior" según la comparación estándar.
Si varias valores de tipos diferentes son evaluados como iguales
(i.e. <literal>0</literal> y <literal>'abc'</literal>), el primero proporcionado
a la función será devuelto.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Si se pasa un array vacío, la función <function>max</function> lanza una <classname>ValueError</classname>.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.0.0</entry>
<entry>
<function>max</function> ahora lanza una <classname>ValueError</classname> en caso de fallo;
previamente, &false; era devuelto y se emitía un error <constant>E_WARNING</constant>.
</entry>
</row>
<row>
<entry>8.0.0</entry>
<entry>
Como las <link linkend="migration80.incompatible.core.string-number-comparision">
comparaciones entre strings y números</link> han sido cambiadas,
<function>max</function> ya no devuelve un valor diferente
basado en el orden de los argumentos en estos casos.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Ejemplo con <function>max</function></title>
<programlisting role="php">
<![CDATA[
<?php
echo max(2, 3, 1, 6, 7), PHP_EOL; // 7
echo max(array(2, 4, 5)), PHP_EOL; // 5
// Aquí, comparamos -1 < 0, por lo que 'hello' es el valor más grande
echo max('hello', -1), PHP_EOL; // hello
// Con varios arrays de diferentes tamaños, max devuelve
// el más largo
$val = max(array(2, 2, 2), array(1, 1, 1, 1)); // array(1, 1, 1, 1)
var_dump($val);
// Varios arrays de la misma longitud son comparados de izquierda a derecha
// también, en nuestro ejemplo: 2 == 2, pero 5 > 4
$val = max(array(2, 4, 8), array(2, 5, 1)); // array(2, 5, 1)
var_dump($val);
// Si se proporciona un array y un no-array, el array será siempre
// devuelto, sabiendo que las comparaciones tratan los arrays como
// más grandes que cualquier valor
$val = max('string', array(2, 5, 7), 42); // array(2, 5, 7)
var_dump($val);
// Si un argumento es NULL o un booleano, será comparado con otros
// valores utilizando la regla FALSE < TRUE según los otros tipos concernidos
// En el ejemplo de abajo, -10 es tratado como TRUE en la comparación
$val = max(-10, FALSE); // -10
var_dump($val);
// Por otro lado, 0 es tratado como FALSE, por lo que es "más pequeño que" TRUE
$val = max(0, TRUE); // TRUE
var_dump($val);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>min</function></member>
<member><function>count</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->