From 0833c63fa2ddba335000a45c203bbed6dd753b81 Mon Sep 17 00:00:00 2001 From: Philip Olson <philip@php.net> Date: Sun, 2 Jun 2002 04:36:16 +0000 Subject: [PATCH] Added some examples. Returns NULL on failure. Will fail if one variable is undefined. See also max(). git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@84374 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/math/functions/min.xml | 37 +++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/reference/math/functions/min.xml b/reference/math/functions/min.xml index 9542798caf..cbac548e78 100644 --- a/reference/math/functions/min.xml +++ b/reference/math/functions/min.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/math.xml, last change in rev 1.2 --> <refentry id="function.min"> <refnamediv> @@ -25,7 +25,8 @@ <para> In the first variant, you need at least two parameters and <function>min</function> returns the lowest of these values. - You can compare an unlimited number of values. + You can compare an unlimited number of values. If one of the + variables is undefined, <function>min</function> will fail. </para> <para> In the second variant, <function>min</function> @@ -36,7 +37,37 @@ will be treated as floats, and a float is returned. If none of the values is a float, all of them will be treated as <type>integer</type>s, - and an integer is returned. + and an integer is returned. Upon failure, <function>min</function> + returns <type>NULL</type> and an error of level <constant>E_WARNING</constant> + is generated. + </para> + <para> + <informalexample> + <programlisting> +<![CDATA[ +<?php +$a = 4; +$b = 9; +$c = 3; +$arr = array(99, 34, 11); + +// You may want to implement your own error checking in +// case of failure (a variable may not be set) +if (!$min_value = @min($a, $b, $c)) { + echo "Could not get min value, please try again."; +} else { + echo "min value is $min_value"; +} + +print min($arr); // 11 + +?> +]]> + </programlisting> + </informalexample> + </para> + <para> + See also <function>max</function>. </para> </refsect1> </refentry>