php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #40569 "Function arguments", section "Variable-length argument lists": give examples
Submitted: 2007-02-20 23:16 UTC Modified: 2007-03-23 17:27 UTC
From: burg1 at gmx dot net Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: burg1 at gmx dot net
New email:
PHP Version: OS:

 

 [2007-02-20 23:16 UTC] burg1 at gmx dot net
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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-23 16:02 UTC] vrana@php.net
Examples are on the func_*_arg* pages which are linked from this section.
 [2007-03-23 17:27 UTC] burg1 at gmx dot net
No! The three func_*_arg* pages only contain one example about the usage of the func_*_arg* function.
The examples I am asking for are about the usage of variable-argument functions in general, and they (or similar) are not included anywhere in the docs.
Why don't you just include them? More examples make the docs better, since anybody who is not interested can easily skip them. But for those who don't know how things work, examples are a GREAT way of showing.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Jun 06 07:01:26 2020 UTC