Solution 1
Why is customError() being passed as a string?
Because PHP allows functions to be referenced by their name as a string. For example, functions like usort() or ob_start() accept a string that specifies the function to be called. If you didn’t enclose the name in quotes, PHP would either treat it as a constant or try to execute it directly (if followed by parentheses).
This approach works within PHP’s parsing rules—there are no true function pointers, so strings are used to reference callable functions.
Why isn’t $test defined?
That’s intentional. The undefined $test triggers an error, allowing the custom error handler you set up (customError) to catch and process it.