code_junkie

PHP's create_function() versus just using eval()

Nov 13th, 2011
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. $myFunction = create_function('$foo', 'return $foo;');
  2. $myFunction('bar'); //Returns bar
  3.  
  4. do{
  5. $myFunction = 'createdFunction_'.rand();
  6. }
  7. while(function_exists($myFunction));
  8. eval("function $myFunction($foo) { return $foo; }");
  9. $myFunction('bar'); //Returns bar
Add Comment
Please, Sign In to add comment