970_90

Thursday, 2 October 2014

SPL autoload extensions in PHP

spl autoload extensions in PHP

string spl_autoload_extensions ([ string $file_extensions ] )
Register and return default file extensions for spl_autoload
This function can modify and check the file extensions that the built in __autoload() fallback function spl_autoload() will be using.
<?php
    public function __construct() 
    {
        spl_autoload_register(array($this,'library'));
    }

    public function library($class)
    {
        if (is_string($class) && null === $class) {
            set_include_path(get_include_path().PATH_SEPARATOR.'app/lib/');
            spl_autoload_extension('.php');
            spl_autoload($class);
        }
        return false;
    }
?>

No comments:

Post a Comment