Update base.php

This commit is contained in:
Namhyeon Go 2018-04-29 00:45:21 +09:00 committed by GitHub
parent cd8e6f45e4
commit a87edc8740
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,6 +151,38 @@ if(!function_exists("get_value_in_object")) {
}
}
// error handler
if(!function_exists("set_error")) {
function set_error($msg, $code="ERROR") {
global $scope;
$scope['errors'][] = $code . ": " . $msg;
}
}
if(!function_exists("get_errors")) {
function get_errors($d=false, $e=false) { // d: display, e: exit
global $scope;
$errors = $scope['errors'];
if($d === true) {
foreach($errors as $err) {
echo $err . PHP_EOL;
}
}
if($e === true) {
exit;
}
return $errors;
}
}
if(!function_exists("show_errors")) {
function show_errors($exit=true) {
return get_errors(true, $exit);
}
}
$scope = array();
set_scope("loaded", array(
@ -158,4 +190,5 @@ set_scope("loaded", array(
"helper" => array(),
"view" => array(),
"route" => array(),
"errors" => array(),
));