Desmond Hume
Desmond Hume

Reputation: 8627

Simplest way to trigger PHP shutdown

Is there a simple way to trigger PHP shutdown so that error_get_last function returns a real error from within a function registered with register_shutdown_function. I need it to test my custom error handling and mailing functions under stress conditions.

Upvotes: 3

Views: 1237

Answers (2)

deceze
deceze

Reputation: 522523

trigger_error("You goin' down!", E_USER_ERROR);

Upvotes: 2

sanyi
sanyi

Reputation: 6249

<?php

function shutdown()
{
    echo "shutdown:\n";
    print_r(error_get_last());
}

register_shutdown_function('shutdown');

throw new Exception("fatal error");

print("END")

Upvotes: 1

Related Questions