/ Published in: PHP
URL: http://www.codediesel.com/php/anonymous-functions-in-php
Expand |
Embed | Plain Text
<?php $multiply = function($multiplier) { return function($x) use ($multiplier) { return $x * $multiplier; }; }; // $mul5 now contains a function that returns a number multiplied by 5 $mult5 = $multiply(5); // $mul7 contains a function that returns a number multiplied by 7 $mult7 = $multiply(7); // Output- // 25 // 35 ?>
You need to login to post a comment.
