Simple PHP PSR-0 Autoload
Here's a simple PHP PSR-0 autoload example:
<?php
// autoload.php
spl_autoload_register( function ( $class )
{
include dirname( __DIR__ ) . DIRECTORY_SEPARATOR . implode( DIRECTORY_SEPARATOR , array_slice( explode( '\\' , $class ) , 0 , -1 ) ) . DIRECTORY_SEPARATOR . str_replace( '_' , DIRECTORY_SEPARATOR , implode( '' , array_slice( explode( '\\' , $class ) , -1 , 1 ) ) ) . '.php';
} );
Written by Matt Helm
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Related Tags
#php
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#