Php Custom Autoload

[Solved] Php Custom Autoload | Php - Code Explorer | yomemimo.com
Question : autoload.php

Answered by : enrico-bisco

The introduction of spl_autoload_register() gave programmers
the ability to create an autoload chain,
a series of functions that can be called to try and load a class or interface.
For example:
<?php
function autoloadModel($className) { $filename = "models/" . $className . ".php"; if (is_readable($filename)) { require $filename; }
}
function autoloadController($className) { $filename = "controllers/" . $className . ".php"; if (is_readable($filename)) { require $filename; }
}
spl_autoload_register("autoloadModel");
spl_autoload_register("autoloadController");

Source : https://stackoverflow.com/questions/3607543/what-is-autoload-in-php | Last Update : Tue, 30 Mar 21

Answers related to php custom autoload

Code Explorer Popular Question For Php