note 108889 modified in function.create-function by danbrown

From: Date: Fri, 01 Jun 2012 15:28:39 +0000
Subject: note 108889 modified in function.create-function by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188363@lists.php.net to get a copy of this message
For those who want to create closure with create_function, don't bother, you can't.
Use create_closure instead :p

<?php
//same thing as create_function, but returns a closure..( 5.4)
function create_closure($args, $body){
 return eval("return function($args){ {$body} };");
}
?> --was-- For those who want to create closure with create_function, don't bother, you can't. Use create_closure instead :p //same thing as create_function, but returns a closure..( 5.4) function create_closure($args, $body){ return eval("return function($args){ {$body} };"); } http://php.net/manual/en/function.create-function.php

« previous php.notes (#188363) next »