Search code snippets, questions, articles...

spl_autoload_register();

<?php

spl_autoload_register('myAutoload');

function myAutoload($placeholder) {
    $url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

    if(strpos($url, 'includes') !== false){
        $path = '../classes/';
    }else{
        $path = 'classes/';
    }

    $extention = '.class.php';

    require_once $path . $placeholder . $extention;
}
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.

autoload

Was this helpful?
0 Comments