PHP Classes

File: autoloader.php

Recommend this page to a friend!
  Classes of Stefan Kientzler   PHP Google Contacts API   autoloader.php   Download  
File: autoloader.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Google Contacts API
Access Google contacts with the Google People API
Author: By
Last change:
Date: 1 year ago
Size: 844 bytes
 

Contents

Class file image Download
<?php
spl_autoload_register
(function(string $strClassName)
{
   
$strInclude = '';
    if (
strpos($strClassName, '\\') > 1) {
       
// replace the namespace prefix with the base directory, replace namespace
        // separators with directory separators in the relative class name, append
        // with .php
       
$strInclude = str_replace('\\', DIRECTORY_SEPARATOR, $strClassName) . '.php';
       
$strFilename = dirname(__FILE__) . '/' . $strInclude;
        if (!
file_exists($strFilename)) {
           
$strInclude = 'Vendor' . DIRECTORY_SEPARATOR . $strInclude;
        }
    }

   
// if the file exists, require it
   
if (strlen($strInclude) > 0) {
       
$strInclude = dirname(__FILE__) . '/' . $strInclude;
        if (
file_exists($strInclude)) {
            require
$strInclude;
        }
    }
});