Today we will look at the lambda function.
Lambda functions are also called anonymous functions.
It's called anonymous.
Lambda functions do not have names.
In other words, it's called a closure.
variable name = function(){ };
It consists of the above structure.
We use lambda functions by assigning them to variables.
To call the lambda function, the variable name(); is.
variable name = function(){ }; variable name();
Now, let's use it.
<?php $disney = function(){ echo "Hi I'm a lambda function"; }; $disney(); ?>
Here is the result of the above code:
You can also use parameters and arguments just like regular functions.
variable name = function ($param, $param2){ }; variable name('arg','arg2');
Then let's look at an example.
<?php $disney = function($param){ echo $param; }; $disney("Hi I'm a lambda function"); ?>
Here is the result of the above code:
Thank you for visiting. If you have any inquiry or explanation of mistakes, please use the comments below.
//=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']?>ALL COMMENTS 0
Sort by