inizializzazione classe ErrorHandler (parte 105)
1 files added
1 files modified
| | |
| | | |
| | | declare(strict_types= 1); |
| | | |
| | | set_error_handler(function( |
| | | int $errno, |
| | | string $errstr, |
| | | string $errfile, |
| | | int $errline |
| | | ): bool |
| | | { |
| | | throw new ErrorException($errstr,0, $errno, $errfile, $errline); |
| | | }); |
| | | spl_autoload_register(function ($class) { |
| | | require "src/". str_replace("\\", "/", $class). ".php"; |
| | | }); |
| | | |
| | | set_error_handler("Framework\ErrorHandler::handleError"); |
| | | |
| | | |
| | | set_exception_handler(function (Throwable $exception) { |
| | | static $show_errors = false; |
| | | static $show_errors = true; |
| | | |
| | | if($exception instanceof Framework\Exceptions\PageNotFoundException) { |
| | | http_response_code(404); |
| | |
| | | throw $exception; |
| | | }); |
| | | |
| | | spl_autoload_register(function ($class) { |
| | | require "src/". str_replace("\\", "/", $class). ".php"; |
| | | }); |
| | | |
| | | $path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
| | | if ($path === false) { |
New file |
| | |
| | | <?php |
| | | |
| | | declare(strict_types= 1); |
| | | |
| | | namespace Framework; |
| | | |
| | | use ErrorException; |
| | | |
| | | class ErrorHandler { |
| | | public static function handleError( |
| | | int $errno, |
| | | string $errstr, |
| | | string $errfile, |
| | | int $errline |
| | | ): bool |
| | | { |
| | | throw new ErrorException($errstr,0, $errno, $errfile, $errline); |
| | | } |
| | | } |