Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. 1. call_user_func_array passes the callback function an array of parameters.
  2.  
  3. 2. $args = func_get_args();
  4.  
  5. 2a.
  6.  
  7. array (size=3)
  8. 0 => string 'This is Episode Number' (length=22)
  9. 1 => int 4
  10. 2 =>
  11. array (size=2)
  12. 'topic' => string 'Events' (length=6)
  13. 'function' => string 'func_get_args' (length=13)
  14.  
  15.  
  16. 2b. True
  17.  
  18. Code Challenge 2
  19.  
  20. function my_callback( $value ) {
  21.  
  22. // Get the list of arguments that this function received
  23. $args = func_get_args();
  24.  
  25. var_dump( $args );
  26.  
  27. // slice out $value from $args to get the argument list
  28. // 1 = offset value, 2 = number of values to return
  29. $args = array_slice( $args, 1, 2 );
  30.  
  31. var_dump( $args );
  32.  
  33. // return sprintf( '%s %d', $value, $args[0] );
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement