What are the advantages and disadvantages of using a global variable for autoload functions in PHP?

Using a global variable for autoload functions in PHP can make it easy to access the function from anywhere in the code. However, it can also lead to potential conflicts with other global variables or functions, making the code harder to maintain and debug.

// Autoload function using a global variable
$autoload_function = function($class_name) {
    // Autoload logic here
};

spl_autoload_register($autoload_function);