PHP Closure and Lazy Loading

What is the Closures?

Let’s define firstly what is the anonymous function? If you are a front-end developer and have worked with JavaScript, you should be already familiar with anonymous functions. These pretty useful to write short inline functions, define callback etc.

An anonymous function is a function that was declared without any named identifier to refer to it. Here is the PHP implementation of anonymous function:

<?php
$anonymousfunctionReference = function(){
    echo "Anonymous function called"
};

echo $anonymousfunctionReference();

Continue reading

Advertisements