How can I find the arguments in a php function?

bladerz

I know how to check with func_num_args for the number of arguments for a function, but how can I get these arguments inside the php function:

<?php
function test() {
        echo func_num_args(); //returns 2
        echo $argv[1]; //this doesn't work
}

test("aa","bb");

?>
sol

You can call func_get_args() to obtain the array of arguments passed to the function.

For your example, simply add

$args = func_get_args();

And it should work as intended.

There also is func_get_arg, which returns a single argument:

echo func_get_arg(1); // prints second argument

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How can I see function arguments in IPython Notebook Server 3?

From Java

How can I get the arguments called in jest mock function?

From Dev

How can I create a function with a variable number of arguments?

From Dev

How can I make a function with optional arguments in C?

From Dev

How can I build a function that can receive 3 or 4 arguments ?

From Dev

How can I parse command line arguments in PHP?

From Dev

PHP how I can pass arguments to constant

From Dev

How can I pass all arguments to my callback function?

From Dev

How can I "expand" a list to be arguments to a function?

From Dev

How can I call a function in a vbscript with command line arguments?

From Dev

How can I find the arguments in a php function?

From Dev

How can I print the function head, including name, arguments, and docstring?

From Dev

How can I pass arguments in .click() function?

From Dev

How can I line up/indent function arguments up to (

From Dev

How can I pass arguments to the function pointer in following code?

From Dev

How can I check if a function is defined in the chaiscript and how can I execute it with typed arguments?

From Dev

PHP - How can I create a recursive function?

From Dev

How can I call multiple commands as arguments to a function?

From Dev

How can I mention keyword arguments in php constructor?

From Dev

How can I "expand" a list to be arguments to a function?

From Dev

How can I find out the number of arguments that are actually passed to a bash function?

From Dev

How can I call function with arguments specified in separate varible (object)?

From Dev

How can I check if a function is defined in the chaiscript and how can I execute it with typed arguments?

From Dev

How can I write a bash function that puts all arguments into quotes?

From Dev

How can I find the function of a python module?

From Dev

How can I find the executable path of php?

From Dev

TypeChecker API: How do I find inferred type arguments to a function?

From Dev

How can I find exact value for this function?

From Dev

How can I pass a vector as variable arguments into a function in R

Related Related

  1. 1

    How can I see function arguments in IPython Notebook Server 3?

  2. 2

    How can I get the arguments called in jest mock function?

  3. 3

    How can I create a function with a variable number of arguments?

  4. 4

    How can I make a function with optional arguments in C?

  5. 5

    How can I build a function that can receive 3 or 4 arguments ?

  6. 6

    How can I parse command line arguments in PHP?

  7. 7

    PHP how I can pass arguments to constant

  8. 8

    How can I pass all arguments to my callback function?

  9. 9

    How can I "expand" a list to be arguments to a function?

  10. 10

    How can I call a function in a vbscript with command line arguments?

  11. 11

    How can I find the arguments in a php function?

  12. 12

    How can I print the function head, including name, arguments, and docstring?

  13. 13

    How can I pass arguments in .click() function?

  14. 14

    How can I line up/indent function arguments up to (

  15. 15

    How can I pass arguments to the function pointer in following code?

  16. 16

    How can I check if a function is defined in the chaiscript and how can I execute it with typed arguments?

  17. 17

    PHP - How can I create a recursive function?

  18. 18

    How can I call multiple commands as arguments to a function?

  19. 19

    How can I mention keyword arguments in php constructor?

  20. 20

    How can I "expand" a list to be arguments to a function?

  21. 21

    How can I find out the number of arguments that are actually passed to a bash function?

  22. 22

    How can I call function with arguments specified in separate varible (object)?

  23. 23

    How can I check if a function is defined in the chaiscript and how can I execute it with typed arguments?

  24. 24

    How can I write a bash function that puts all arguments into quotes?

  25. 25

    How can I find the function of a python module?

  26. 26

    How can I find the executable path of php?

  27. 27

    TypeChecker API: How do I find inferred type arguments to a function?

  28. 28

    How can I find exact value for this function?

  29. 29

    How can I pass a vector as variable arguments into a function in R

HotTag

Archive