Last active
January 30, 2020 13:13
-
-
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()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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