PHP Classes

File: loader.php

Recommend this page to a friend!
  Classes of Alex McArrow  >  PHP Darts Counter Game  >  loader.php  >  Download  
File: loader.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Darts Counter Game
Manage darts games with multiple players
Author: By
Last change:
Date: 5 months ago
Size: 522 bytes
 

Contents

Class file image Download
<?php

define
('ROOT_PATH', dirname(__FILE__));

function
buildpath(): string
{
    return
implode(DIRECTORY_SEPARATOR, func_get_args());
}

spl_autoload_register(function ($class_name): void {
    if (
file_exists(buildpath(ROOT_PATH, str_ireplace('\\', DIRECTORY_SEPARATOR, strtolower($class_name))) . '.php')) {
        require
buildpath(ROOT_PATH, str_ireplace('\\', DIRECTORY_SEPARATOR, strtolower($class_name))) . '.php';
    } else {
       
trigger_error('Error load class: ' . $class_name, E_USER_ERROR);
    }
});

For more information send a message to info at phpclasses dot org.