Skip to content

Instantly share code, notes, and snippets.

@bradsi
Last active March 30, 2021 12:59
Show Gist options
  • Save bradsi/a857e49f2661f9391e9ede26cfd5c2ed to your computer and use it in GitHub Desktop.
Save bradsi/a857e49f2661f9391e9ede26cfd5c2ed to your computer and use it in GitHub Desktop.
<?php
spl_autoload_register('autoLoader');
function autoLoader($className) {
$url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strpos($url, 'inc')) {
$path = '../classes/';
} else {
$path = 'classes/';
}
$ext = '.class.php';
require_once $path . $className . $ext;
}
<?php
spl_autoload_register('autoLoader');
function autoLoader($className) {
$path = 'classes/';
$ext = './class.php';
require_once $path . $className . $ext;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment