xref: /PHP-8.1/ext/standard/tests/array/max.phpt (revision 25f1c405)
1--TEST--
2max() tests
3--INI--
4precision=14
5--FILE--
6<?php
7
8try {
9    var_dump(max(1));
10} catch (\TypeError $e) {
11    echo $e->getMessage() . "\n";
12}
13
14try {
15    var_dump(max(array()));
16} catch (\ValueError $e) {
17    echo $e->getMessage() . "\n";
18}
19
20try {
21    var_dump(max(new stdclass));
22} catch (\TypeError $e) {
23    echo $e->getMessage() . "\n";
24}
25
26var_dump(max(2,1,2));
27var_dump(max(2.1,2.11,2.09));
28var_dump(max("", "t", "b"));
29var_dump(max(false, true, false));
30var_dump(max(true, false, true));
31var_dump(max(1, true, false, true));
32var_dump(max(0, true, false, true));
33
34?>
35--EXPECT--
36max(): Argument #1 ($value) must be of type array, int given
37max(): Argument #1 ($value) must contain at least one element
38max(): Argument #1 ($value) must be of type array, stdClass given
39int(2)
40float(2.11)
41string(1) "t"
42bool(true)
43bool(true)
44int(1)
45bool(true)
46