<?php
$arr = [];
$highNum = null;
$longest = null;
foreach ($_SERVER as $key => $value) {
$num = strlen($value);
$arr = nl2br("$key: $num\n");
echo $arr;
if ($num > $highNum) {
$highNum = $num;
$longest = $key;
}
}
?>
<p>The longest entry is: <?= htmlentities($_SERVER[$longest]); ?></p>
<p>And its value is: <?= print(strval($highNum)); ?></p>
当我运行代码时,它将打印出最长的条目,但是当我打印出该值时,例如说该值为746,我将得到7461。似乎摆脱了最后一个。如果我从值中删除1,则会得到7451。
这样写:
<p>And its value is: <?= strval($highNum); ?></p>
既然您已经在做echo
,则无需print
再次使用。
注意:成功打印后print
也会返回1
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句