PHP Classes

File: autoload.php

Recommend this page to a friend!
  Classes of Jabran Rafique   CSV Parser   autoload.php   Download  
File: autoload.php
Role: Auxiliary script
Content type: text/plain
Description: Configuration script
Class: CSV Parser
Parse CSV data to indexed or associative arrays
Author: By
Last change:
Date: 8 years ago
Size: 576 bytes
 

Contents

Class file image Download
<?php

/**
 * Autoload file
 *
 * You will not need this if you are using Composer.
 * https://getcomposer.org
 *
 * PSR-4 standard: http://www.php-fig.org/psr/psr-4/
 */

spl_autoload_register(function( $class ) {

   
$prefix = '';

   
$base_dir = defined('CLASS_SRC_DIR') ? CLASS_SRC_DIR : dirname(__FILE__);

   
$len = strlen($prefix);

    if (
strncmp($prefix, $class, $len) !== 0 ) {
        return;
    }

   
$rel_class = substr($class, $len);

   
$file = $base_dir . DIRECTORY_SEPARATOR . str_replace('\\', '/', $rel_class) . '.php';
   
    if (
file_exists($file) ) {
        require
$file;
    }
   
});