- json_encode: documentation ( source)
<?php
function test_func($arg1 = 'a', $arg2 = 'b', $arg3 = 'c', $arg4 = 'd')
{
return json_encode([
'func_num_args' => func_num_args(),
'func_get_args' => func_get_args(),
'direct_args' => [$arg1, $arg2, $arg3, $arg4],
], JSON_PRETTY_PRINT);
}
echo test_func('hello', 'b', 'world');