fork download
  1. <?php
  2.  
  3. class Foo {
  4. function __construct() {
  5. $this->test = array(
  6. 'some_val',
  7. function() {
  8. $args = func_get_args();
  9. $username = isset($args[0]) ? $args[0] : false;
  10. return "hey" . (is_string($username) ? ", {$username}!" : "!");
  11. }
  12. );
  13. }
  14. }
  15.  
  16. $var = new Foo;
  17.  
  18. echo $var->test[1]() . PHP_EOL; # hey!
  19. echo $var->test[1]('Arc') . PHP_EOL; # hey, Arc!
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
hey!
hey, Arc!