Skip to content
This repository was archived by the owner on May 28, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
70 changes: 35 additions & 35 deletions assignment1/errors.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<?php
// Max time
set_time_limit(0);
ini_set('memory_limit', '1024M');
// Error reporting
error_reporting(-1);
ini_set('display_errors', 1);
// Handle errors as exceptions
function errorToExceptionHandler($errno, $errstr, $errfile, $errline)
{
throw new ErrorException($errstr, $errno, 1, $errfile, $errline);
}
function fatalErrorHandler()
{
$error = error_get_last();
if ($error !== null)
{
errorToExceptionHandler($error['type'], $error['message'], $error['file'], $error['line']);
}
}
function uncaughtExceptionHandler(Exception $exception)
{
echo '<pre>'
. 'ERROR: ' . $exception->getMessage() . ' :: ' . $exception->getCode() . "\n"
. 'In ' . $exception->getFile() . ':' . $exception->getLine() . "\n"
. '-------------------------------------------------------------------------------------------------------' . "\n"
. $exception->getTraceAsString()
. '</pre>';
}
register_shutdown_function('fatalErrorHandler');
set_exception_handler('uncaughtExceptionHandler');
set_error_handler('errorToExceptionHandler');
<?php

// Max time
set_time_limit(0);
ini_set('memory_limit', '1024M');

// Error reporting
error_reporting(-1);
ini_set('display_errors', 1);

// Handle errors as exceptions
function errorToExceptionHandler($errno, $errstr, $errfile, $errline)
{
throw new ErrorException($errstr, $errno, 1, $errfile, $errline);
}
function fatalErrorHandler()
{
$error = error_get_last();
if ($error !== null)
{
errorToExceptionHandler($error['type'], $error['message'], $error['file'], $error['line']);
}
}
function uncaughtExceptionHandler(Exception $exception)
{
echo '<pre>'
. 'ERROR: ' . $exception->getMessage() . ' :: ' . $exception->getCode() . "\n"
. 'In ' . $exception->getFile() . ':' . $exception->getLine() . "\n"
. '-------------------------------------------------------------------------------------------------------' . "\n"
. $exception->getTraceAsString()
. '</pre>';
}
register_shutdown_function('fatalErrorHandler');
set_exception_handler('uncaughtExceptionHandler');
set_error_handler('errorToExceptionHandler');
Loading