What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.



func_get_arg — Gets a single argument from the argument list passed to a function.


mixed func_get_arg(argument_number);
integer argument_number:



An item from an argument list; FALSE if func_get_arg() is called in global scope

func_get_arg() is used to retrieve a single argument from the list of arguments passed to a user-defined function. It allows the programmer to easily create functions that accept variable-length argument lists.

The argument retrieved is the argument present at the offset specified by argument_number . The argument list starts at 0. If the argument specified by argument_number doesn't exist, a warning is generated.


Unlike most functions, func_get_arg() cannot always be used as an argument for some functions. It's better to assign the output of func_get_arg() to a variable and then use the variable as the argument for a function. The following example illustrates the fickleness of this behavior:

// Calling this function will generate a fatal error
function demo_one () {
     return printf ('%s', func_get_arg (0));
demo_one ("Hi");

// Calling this function will not cause an error
function demo_two () {
    printf (func_get_arg (0));
demo_two ("Hi");


PHP Version: 4.0b4+


Example 380. Demonstrate how func_get_arg() works

function demo () {
    $num_args = func_num_args ();

    if ($num_args == 0) {
        print "The function was passed no arguments.<br /><br />";

    print "The function was passed $num_args argument(s): <blockquote>";

    for ($offset = 0; $offset < $num_args; ++$offset) {
        $arg = func_get_arg($offset);
        printf ('Argument %d (Offset %d): %s<br />', $offset +1, $offset, $arg);

    print '</blockquote><br />';

demo ();
demo (''); // Empty argument
demo ('', '', '', '', '', ''); // Six empty arguments
demo ('Chili Peppers', 'Ancho', 'Chipolte', 'Habanero', 'Jalapeno', 'Serrano');

PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at The authors of this book have elected not to choose any options under the OPL. This online book was obtained from and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.