PHP 7 >= 7.4.0, PHP 8
sapi_windows_set_ctrl_handler - Set or remove a CTRL event handler
sapi_windows_set_ctrl_handler( callable|null$handler, [bool$add = true] ): bool
Sets or removes a CTRL event handler, which allows Windows CLI processes to intercept or ignore CTRL+C and CTRL+BREAK events. Note that in multithreaded environments, this is only possible when called from the main thread.
A callback function to set or remove. If set, this function will be called whenever a CTRL+C or CTRL+BREAK event occurs. The function is supposed to have the following signature:handler( int$event ): void
The CTRL event which has been received; either PHP_WINDOWS_EVENT_CTRL_C or PHP_WINDOWS_EVENT_CTRL_BREAK.
If true, the handler is set. If false, the handler is removed.
Returns true on success or false on failure.
Show all examples for sapi_windows_set_ctrl_handler