Anonymous functions pre PHP 5.3.0

Is there an alternative to anonymous functions in PHP versions prior to 5.3.0?

+3
source share
3 answers

There is create_function , but this is usually not recommended. If you use OOP, you better define a one-time private member for use with a callback.

+5
source
+2
source

There are two options.

First you need to create a function inside the function. Unfortunately, it will pollute the global namespace.

The second choice is to use create_function .

+2
source

Source: https://habr.com/ru/post/1764362/


All Articles