Railsbin – The vulnerable pastebin service!

User:

Title: Create a branchless autoloader

Content:

/**
*
# Please turn this autoloader into a branchless one.
# Good luck!
# 
*/

spl_autoload_register(function(string $name) : void
{
	if ( ($name[0]==='G') && ($name[3]==='\\') ) # Here is the branch: if (the name starts with 'GDO\\') => include the class.
	{
		$name = GDO_PATH . str_replace('\\', '/', $name) . '.php';
		require $name;

	}
});

Edit | Back