Simple Lambda function layout

<?php
  $lambda = function($name) {
    return "$name is $name.\n";
  };

  function normal($name) {
    return "$name is $name.\n";
  }

  echo $lambda('Brown');
  echo  normal('Green');
?>

Clearly there’s no advantage to the lambda function in this example, but it demonstrates the comparison between “old-school” function definitions and the lambda way of doing the same (useless) thing.

Leave a Reply