Using the PHP Function pcntl_async_signals
A function is a block of code that is called from within another script to perform a specific task. PHP has over 1000 built-in functions that you can use to accomplish almost any task. You can also create your own custom functions to add unique features to your applications.
You can disable PHP functions to prevent them from running in your system if they could pose a security risk. To do this, open your php configuration file and locate the php.ini file, then add a list of functions to disable in a comma-delimited list.
php - pcntl_async_signals
If you want to act on process status changes in a more asynchronous manner, instead of having to poll every time a loop iteration, user function entry or internal function exit, pcntl_async_signals allows you to set a handler for each signal and then wait() on them to ensure they actually get processed (like a real parent process). In this article we'll look at an example of how to implement this to build a simple task management framework that uses pcntl_fork and pcntl_wait.
Unlike other PHP functions, which pass variables by value, the return statement in PHP will accept any type as long as it is valid as a method name. This is because PHP 7 introduces support for Type Declarations in the return statement. If you have not declared the type of your return function, it will throw a Fatal Error.