(PHP 4, PHP 5, PHP 7)
max — 锟揭筹拷锟斤拷锟街�
锟斤拷锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷锟轿拷锟斤拷椋�max() 锟斤拷锟截革拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷址锟斤拷锟斤拷蚋〉锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟揭拷锟斤拷锟斤拷锟斤拷锟斤拷锟� max() 锟结返锟斤拷锟斤拷些值锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟皆比斤拷锟斤拷锟睫讹拷锟街碉拷锟�
Note:
PHP 锟结将锟斤拷锟斤拷值锟斤拷 string 锟斤拷锟斤拷 0锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷值锟斤拷锟斤拷然锟结返锟斤拷一锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷值为 0 锟斤拷锟斤拷锟斤拷锟街碉拷锟�max() 锟结返锟斤拷锟斤拷锟斤拷锟斤拷值锟斤拷 0锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟矫伙拷锟斤拷锟街碉拷锟� 0锟斤拷锟津返回帮拷锟斤拷母锟斤拷顺锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷
values
锟斤拷锟斤拷锟剿讹拷锟街碉拷锟斤拷锟斤拷椤�
value1
Any comparable value.
value2
Any comparable value.
...
Any comparable value.
max() 锟斤拷锟截诧拷锟斤拷锟斤拷锟斤拷值锟斤拷锟斤拷值锟斤拷 If multiple values can be considered of the same size, the one that is listed first will be returned.
When max() is given multiple arrays, the longest array is returned. If all the arrays have the same length, max() will use lexicographic ordering to find the return value.
When given a string it will be cast as an integer when comparing.
Example #1 使锟斤拷 max() 锟斤拷锟斤拷锟斤拷
<?php
echo max(1, 3, 5, 6, 7); // 7
echo max(array(2, 4, 5)); // 5
// When 'hello' is cast as integer it will be 0. Both the parameters are equally
// long, so the order they are given in determines the result
echo max(0, 'hello'); // 0
echo max('hello', 0); // hello
echo max('42', 3); // '42'
// Here 0 > -1, so 'hello' is the return value.
echo max(-1, 'hello'); // hello
// With multiple arrays of different lengths, max returns the longest
$val = max(array(2, 2, 2), array(1, 1, 1, 1)); // array(1, 1, 1, 1)
// 锟皆讹拷锟斤拷锟斤拷椋琺ax 锟斤拷锟斤拷锟斤拷锟揭比较★拷
// 锟斤拷锟斤拷诒锟斤拷锟斤拷校锟�2 == 2锟斤拷锟斤拷 4 < 5
$val = max(array(2, 4, 8), array(2, 5, 7)); // array(2, 5, 7)
// 锟斤拷锟酵憋拷锟斤拷锟斤拷锟斤拷锟酵凤拷锟斤拷锟斤拷锟斤拷为锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟角斤拷锟斤拷锟斤拷锟斤拷为
// 锟斤拷锟街碉拷锟斤拷锟�
$val = max('string', array(2, 5, 7), 42); // array(2, 5, 7)
?>