|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-03-23 16:02 UTC] vrana@php.net
[2007-03-23 17:27 UTC] burg1 at gmx dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 05:00:01 2025 UTC |
Description: ------------ Please include examples on how to define (and call) functions with a variable number of arguments: Example 17.11. Define a function with variable number of arguments: function test() { echo func_get_arg(0); } test('hello'); // prints 'hello' Example 17.12. Other method to define a function with optional second argument function test($foo, $bar=null) { echo $bar; } test('one','two'); // prints 'two' test('one'); // prints nothing Example 17.13. Wrong way to define a function with optional second argument function test($foo, $bar) { ... } test('one'); // gives warning, that argument 2 is missing for test() Why am I asking for this? Because the current explanation "No special syntax is required" is not very descriptive. So my first guess was the wrong way shown in Example 17.13