What does 'unexpected t_function' mean in php?

Example:

$func = function() {
    echo "Hello";
};

This error can arise when you're using anonymous functions in a PHP version that doesn't support them.

Solution:

Upgrade your PHP version or refactor the code to not use anonymous functions.


function sayHello() {
    echo "Hello";
}
sayHello();

Beginner's Guide to PHP