Variable Number Of Arguments
The subject of a variable number of arguements passed to a function pops up quite often. Here we show how easy this is with func_num_args(). The trick to achieving this is to the use of the PHP func_num_args function.
As you can see when you run this code it will print out
5
To get the arguements you can simply use func_get_args(). Lets modify our code a little to see how this works..
5
To get the arguements you can simply use func_get_args(). Lets modify our code a little to see how this works..
The above code will produce an ordered list of the arguemnts passed to it, regardless of the number. The output will look like this.
- the
- cat
- sat
- on
- the
- mat
0 comments:
Post a Comment