Advertisement
touhid_xml

Annonymouse function in php

Jan 26th, 2016
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $add = function($x,$y){
  4.     return $x + $y;
  5. };
  6.  
  7. $sub = function($x,$y){
  8.     return $x - $y;
  9. };
  10.  
  11. $mul = function($x,$y){
  12.     return $x * $y;
  13. };
  14.  
  15. $div = function($x,$y){
  16.     return $x / $y;
  17. };
  18.  
  19. function calculate($x,$y,$fn){
  20.     return $fn($x,$y);
  21. }
  22.  
  23. echo calculate(100,200, $add);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement