fork download
  1. <?php
  2.  
  3. class PMoon{
  4. public $ast = array();
  5.  
  6. public function __construct(){
  7. $this->ast = array('labelStatement' => create_function('$label', 'return array("type" => "LabelStatement",
  8. "label" => $label);'
  9. ));
  10. }
  11. }
  12.  
  13. $moon = new PMoon;
  14. $labelFunc = $moon->ast['labelStatement']('Foo bar');
  15.  
  16. var_dump($labelFunc);
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
array(2) {
  ["type"]=>
  string(14) "LabelStatement"
  ["label"]=>
  string(7) "Foo bar"
}