Php wrapper?

I don't know if the term I'm using is appropriate, but what I'm looking for is similar to what you get with the zend server. Check out this .

It seems like an error, it unloads the request along with the trace parameters and stack parameters, as well as some other information. It allows you to view it in a nice interface. I know that itโ€™s not difficult to do the way you can always make callbacks, but if something like this exists (for free), I would rather use it instead of reinventing the wheel.

+3
source share
2 answers

, ; , ... , , : - (

, , , , , :


, , , - : -, :

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
    $str = '';
    switch ($errno) {
        case E_USER_ERROR:
            $str .= "<b>My ERROR</b> [$errno] $errstr<br />\n";
            $str .= "  Fatal error on line $errline in file $errfile";
            $str .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
            break;
        case E_USER_WARNING:
            $str .= "<b>My WARNING</b> [$errno] $errstr<br />\n";
            break;
        case E_USER_NOTICE:
            $str .= "<b>My NOTICE</b> [$errno] $errstr<br />\n";
            break;
        default:
            $str .= "Unknown error type: [$errno] $errstr<br />\n";
            break;
    }
    $str .= print_r($_GET, true);

    $str .= "\n";
    file_put_contents(dirname(__FILE__) . '/log.txt', $str, FILE_APPEND);

    /* Don't execute PHP internal error handler */
    return true;
}

, , , $_GET .
(, - / )


:

$old_error_handler = set_error_handler("myErrorHandler");


, , :

trigger_error("test of E_USER_ERROR", E_USER_ERROR);
trigger_error("test of E_USER_WARNING", E_USER_WARNING);
trigger_error("test of E_USER_NOTICE", E_USER_NOTICE);


, - : http://tests/temp/temp.php?a=10&test=glop&hello=world; , :

$ cat log.txt
<b>My ERROR</b> [256] test of E_USER_ERROR<br />
  Fatal error on line 34 in file /home/squale/developpement/tests/temp/temp.php, PHP 5.3.0RC4 (Linux)<br />
Array
(
    [a] => 10
    [test] => glop
    [hello] => world
)

<b>My WARNING</b> [512] test of E_USER_WARNING<br />
Array
(
    [a] => 10
    [test] => glop
    [hello] => world
)

<b>My NOTICE</b> [1024] test of E_USER_NOTICE<br />
Array
(
    [a] => 10
    [test] => glop
    [hello] => world
)

... , , ; , , , , ; -)


, (, , ...); , , : - (

, , , ...
( , - , ? , , ;-) , , , ))

, !

+3

PHP.

, set_error_handler() set_exception_handler().

print_r() _GET, _POST, _SERVER, _COOKIE, _SESSION .., /SMS . . . ( ).

PHP. - , / . ...

+2

Source: https://habr.com/ru/post/1714636/


All Articles