How can autoloading help improve the efficiency and security of file includes in PHP?

Autoloading in PHP can improve efficiency and security by dynamically loading classes only when they are needed, reducing the number of files included in each request. This can lead to faster load times and lower memory usage. Additionally, autoloading helps prevent naming conflicts and ensures that classes are only loaded from trusted sources.

spl_autoload_register(function ($class_name) {
    include $class_name . '.php';
});