sapi_windows_set_ctrl_handler() - php 选项信息函数
sapi_windows_set_ctrl_handler()
(PHP 7 >= 7.4.0)
Set or remove a CTRL event handler
说明
sapi_windows_set_ctrl_handler(callable $callable[,bool $add=TRUE
]): boolSets or removes aCTRLevent handler, which allows Windows CLI processes to intercept or ignoreCTRL+CandCTRL+BREAKevents. Note that in multithreaded environments, this is only possible when called from the main thread.
参数
$callableA callback function to set or remove. If set, this function will be called whenever aCTRL+CorCTRL+BREAKevent occurs. The function is supposed to have the following signature:handler(int $event): void$eventTheCTRLevent which has been received;eitherPHP_WINDOWS_EVENT_CTRL_C
orPHP_WINDOWS_EVENT_CTRL_BREAK
.Setting aNULL
$callablecauses the process to ignoreCTRL+Cevents, but notCTRL+BREAKevents.
IfTRUE
, the handler is set.IfFALSE
, the handler is removed.
返回值
成功时返回TRUE
,或者在失败时返回FALSE
。
范例
Basicsapi_windows_set_ctrl_handler()Usage
This example shows how to interceptCTRLevents.
参见
sapi_windows_generate_ctrl_event()
Send a CTRL event to another process