From eb8e5f95b9bb186575f7a583a7c194aef088acf9 Mon Sep 17 00:00:00 2001 From: jeroenrnl Date: Wed, 5 Jun 2013 11:31:10 +0200 Subject: [PATCH] Made autoload a little more robust --- php/include.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/php/include.inc.php b/php/include.inc.php index 85e2cb5..2109360 100644 --- a/php/include.inc.php +++ b/php/include.inc.php @@ -20,12 +20,20 @@ * @todo return false should change into an exception */ + function zophAutoload($file) { + if(is_readable($file)) { + require_once $file; + } + } + function zophAutoloadClass($class) { - @include_once "classes/" . $class . ".inc.php"; + $file="classes/" . $class . ".inc.php"; + zophAutoload($file); } function zophAutoloadInterface($interface) { - @include_once "interfaces/" . $interface . ".inc.php"; + $file="interfaces/" . $interface . ".inc.php"; + zophAutoload($file); } spl_autoload_register("zophAutoloadClass"); spl_autoload_register("zophAutoloadInterface");