php定义参数数量可变的函数用法实例
php定义参数数量可变的函数用法实例
这篇文章主要介绍了php定义参数数量可变的函数用法,实例分析了func_get_args的使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了php定义参数数量可变的函数用法。分享给大家供大家参考。具体分析如下:
php中的的函数参数可以不固定,甚至不用定义参数,在函数内部使用func_get_args()函数获得参数列表,调用时可以为函数指定任意参数,非常方便
?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function addanything (){ $total = 0; $args = func_get_args (); for ($i = 0; $i if (is_int ($args[$i])){ $total += $args[$i]; } } return $total; } echo addanything (1,5,7,8,11) . " ?> |
希望本文所述对大家的php程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1
Powerful PHP integrated development environment