[ create a new paste ] login | about

Link: http://codepad.org/AUkcKHPC    [ raw code | output | fork ]

PHP, pasted on Aug 30:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
class foo{
 public $bar = NULL;

 public function boo(){
   $haha = $this->bar;
   $haha();
 }

}

$mee = new foo();

//save a closure function on the property
$mee->bar = function(){
  echo 'hahaha';
};

//invoke the closure function by using a class method
$mee->boo();
?>


Output:
1
2

Parse error: syntax error, unexpected T_FUNCTION on line 15


Create a new paste based on this one


Comments: