Created
July 15, 2015 18:00
-
-
Save patrickodacre/20687d0e983ea9fe6f45 to your computer and use it in GitHub Desktop.
This file contains 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
1. call_user_func_array passes the callback function an array of parameters. | |
2. $args = func_get_args(); | |
2a. | |
array (size=3) | |
0 => string 'This is Episode Number' (length=22) | |
1 => int 4 | |
2 => | |
array (size=2) | |
'topic' => string 'Events' (length=6) | |
'function' => string 'func_get_args' (length=13) | |
2b. True | |
Code Challenge 2 | |
function my_callback( $value ) { | |
// Get the list of arguments that this function received | |
$args = func_get_args(); | |
var_dump( $args ); | |
// slice out $value from $args to get the argument list | |
// 1 = offset value, 2 = number of values to return | |
$args = array_slice( $args, 1, 2 ); | |
var_dump( $args ); | |
// return sprintf( '%s %d', $value, $args[0] ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment