I am redirecting all http request to index.php , router.php and others config file are being called by index.php , I am having a router which will look for handler if the file exist but i wonder how i access the the handler's variable in my controller.
Here is my index.php , will include all the config file like db and site setting
index.php
require_once ('include/config.inc.php');
require_once ('include/mysql.inc.php');
require_once ('include/shared_function.inc.php');
require_once ('include/router.inc.php');
Here is my router , will check for handlers if exist.
router.php
front_controller(){
if(file_exists('handlers/login-handler.php')){
include_once('handlers/login-handler.php');
}
include_once( 'login.php' );
}
front_controller();
Here is the file i handle request , normally i will keep an array of errors to display back in form
handlers/login-handler.php
//initialise variable to keep error
$errors=array();
if(request==post){
...
//validate post data
...
}
after the handlers being called , here is my controller which will display back the form or result.
login.php
//here comes the error , undefined variable
print_r($errors);
Please suggest me a good way to overcome this problem ...