Skip to content

Instantly share code, notes, and snippets.

@akash-coded
Last active January 30, 2020 13:13
Show Gist options
  • Save akash-coded/a50f1f727f8f61734ed3ccf76b618097 to your computer and use it in GitHub Desktop.
Save akash-coded/a50f1f727f8f61734ed3ccf76b618097 to your computer and use it in GitHub Desktop.
How to use varargs in PHP with token(...) symbol and func_get_args()
<?php
class Test
{
public function testing(...$args)
{
$x = func_num_args();
print_r($x);
echo "</br>";
print_r($args);
echo "</br>";
echo "</br>";
}
}
$obj = new Test();
$obj->testing();
$obj->testing('Akash Das');
$obj->testing('Akash', 14);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment