//自执行函数计算1到100的总和 <?php (function($length){ $total = 0; for($i=0; $i<$length; $i++){ $total += $i; }; echo $total; })(100);