You must use set_error_handler and set a function of yours to handle and display errors as you wish
Source: http://www.php.net/manual/en/function.set-error-handler.php
<?php
// error handler function
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting
return;
}
//CUSTOMIZAR SUAS TELAS DE ERRO AQUI
switch ($errno) {
case E_USER_ERROR:
echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
echo " Fatal error on line $errline in file $errfile";
echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
echo "Aborting...<br />\n";
exit(1);
break;
case E_USER_WARNING:
echo "<b>My WARNING</b> [$errno] $errstr<br />\n";
break;
case E_USER_NOTICE:
echo "<b>My NOTICE</b> [$errno] $errstr<br />\n";
break;
default:
echo "Unknown error type: [$errno] $errstr<br />\n";
break;
}
/* Don't execute PHP internal error handler */
return true;
}
// function to test the error handling
function scale_by_log($vect, $scale)
{
if (!is_numeric($scale) || $scale <= 0) {
trigger_error("log(x) for x <= 0 is undefined, you used: scale = $scale", E_USER_ERROR);
}
if (!is_array($vect)) {
trigger_error("Incorrect input vector, array of values expected", E_USER_WARNING);
return null;
}
$temp = array();
foreach($vect as $pos => $value) {
if (!is_numeric($value)) {
trigger_error("Value at position $pos is not a number, using 0 (zero)", E_USER_NOTICE);
$value = 0;
}
$temp[$pos] = log($scale) * $value;
}
return $temp;
}
// set to the user defined error handler
$old_error_handler = set_error_handler("myErrorHandler");
// trigger some errors, first define a mixed array with a non-numeric item
echo "vector a\n";
$a = array(2, 3, "foo", 5.5, 43.3, 21.11);
print_r($a);
// now generate second array
echo "----\nvector b - a notice (b = log(PI) * a)\n";
/* Value at position $pos is not a number, using 0 (zero) */
$b = scale_by_log($a, M_PI);
print_r($b);
// this is trouble, we pass a string instead of an array
echo "----\nvector c - a warning\n";
/* Incorrect input vector, array of values expected */
$c = scale_by_log("not array", 2.3);
var_dump($c); // NULL
// this is a critical error, log of zero or negative number is undefined
echo "----\nvector d - fatal error\n";
/* log(x) for x <= 0 is undefined, you used: scale = $scale" */
$d = scale_by_log($a, -2.5);
var_dump($d); // Never reached
?>
See if the Xdebug is installed
– rray
@lost not installed yet, I will test with it if change anything
– RodrigoBorth
I tested in windows, I removed only the comment from the line
[XDebug]
zend_extension = caminho
php.ini and the error message came with that orange.– rray
I’m installing Xdebug here, it’s full of dependencies, which have their dependencies, and debian doesn’t make life easy at all kkkkk
– RodrigoBorth
@lost was the same Xdebug :D puts as answer so I can mark as correct
– RodrigoBorth
I think you better write the answer and put what steps/commands you ran on linux and also if you needed to change php.ini or ext folder to install Xdebug.
– rray
Okay, I’ll do that then
– RodrigoBorth
If you just want a more beautiful and organized way to visualize errors, it is worth taking a look at this project: https://github.com/JosephLenton/PHP-Error
– Kazzkiq
a good thing of the answer / option using set_error_handler is that it frees you from the need to configure Xdebug (option this may not even be available on shared host) at the same time it gives you total freedom to work the layout of the wrong screen ;-)
– Marcelo Bezerra bovino
Actually on shared servers do not have this possibility, but on these servers I will not display errors, I have to display them for production and then hide any error that may occur for aesthetic reasons to the client
– RodrigoBorth