journal
all ![]() | Rob is 20,118 days old today. |
Sept 2018 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Nov 2018 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 2017 jan feb mar apr may jun jul aug sep oct nov dec
2019 jan feb mar apr may jun jul aug sep oct nov dec |< << more >> >| |
Entries this day: learning-php learning php 07:10 Sunday 07 October 2018 JSTI have started going through Modernizing Legacy Applications in PHP for AB website, and now the database is loaded via an autoloader. * @license https://opensource.org/licenses/bsd-license.php BSD */ /** * Autoloads classes. * */ namespace Mlaphp; class Autoloader { public function load($class) { // strip off any leading namespace separator from PHP 5.3 $class = ltrim($class, '\\'); // the eventual file path $subpath = ''; // is there a PHP 5.3 namespace separator? $pos = strrpos($class, '\\'); if ($pos !== false) { // convert namespace separators to directory separators $ns = substr($class, 0, $pos); $subpath = str_replace('\\', DIRECTORY_SEPARATOR, $ns) . DIRECTORY_SEPARATOR; // remove the namespace portion from the final class name portion $class = substr($class, $pos + 1); } // convert underscores in the class name to directory separators $subpath .= str_replace('_', DIRECTORY_SEPARATOR, $class); // the path to our central class directory location $dir = dirname(__DIR__); // prefix with the central directory location and suffix with .php, // then require it. $file = $dir . DIRECTORY_SEPARATOR . $subpath . '.php'; require $file; } } I had to tweak the file path for the database file from classes/database/class.database.php to classes/Database/Database.php And add prev day next day |