<!-- 参数计数 -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<?php
function countlist()
{
if(func_num_args() == 0){
return false;
}
else{
$count = 0;
for($i=0;$i < func_num_args();$i++){
$count += func_get_arg($i);
}
return $count;
}
}
echo countlist(1,5,9);
?>
</body>
</html>
PHP学习笔记——参数计数
本文介绍了一个简单的PHP自定义函数,该函数用于计算传入参数的总和。通过使用`func_num_args()`和`func_get_arg()`函数,实现了动态参数数量的支持。此示例展示了如何在PHP中处理不确定数量的参数。

被折叠的 条评论
为什么被折叠?



