386 of 410 menu

The func_get_arg Function

The func_get_arg function returns the specified argument from the list of parameters passed to the function. It accepts the argument index as a parameter (starting from 0). This function must be called only inside a user-defined function.

Syntax

func_get_arg(int $index);

Example

Get the first argument (index 0) from those passed to the function:

<?php function test() { $res = func_get_arg(0); echo $res; } test('abcde'); ?>

Code execution result:

'abcde'

Example

Get the second argument (index 1) from the passed parameters:

<?php function testArgs() { $res = func_get_arg(1); return $res; } echo testArgs(1, 2, 3); ?>

Code execution result:

2

See Also

  • the func_get_args function,
    which returns all function arguments as an array
  • the func_num_args function,
    which returns the number of arguments passed
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline