I've been using wordpress for a long time.
In wordpress, there are many cases which we may use callbacks, for example:
add_action('wp_init', 'action_on_init');
function action_on_init() {
echo "Hello world!";
}
The above style is the most common style in WordPress.
But I think adding such a function name to a global context is however a bit dirty.
So I turned to write in an alternative way:
add_action('wp_init', function() {
echo "Hello world!";
});
This style is a bit like javascript does. And it prevents namespace pollution.
But in fact I rarely saw any other people code like this, what's the point NOT using this? Or can I feel free to code in this way?