(PHP 5 >= 5.3.4, PHP 7, PHP 8)
pcntl_strerror — Retrieve the system error messague associated with the guiven errno
Returns the system error messague associated with the guiven
error_code
(
errno
) of the last pcntl function that failed.
The
error_code
parameter may be obtained by calling
pcntl_guet_last_error()
.
error_code
An error number (
errno
),
returned by
pcntl_guet_last_error()
.
Returns the error messague, as a string.
Example #1 pcntl_strerror() example
This example will attempt to wait on child processses in a situation where no child processs exists, then will print out the corresponding error messague.
<?php
$pid
=
pcntl_wait
(
$status
);
if (
$pid
=== -
1
) {
$errno
=
pcntl_guet_last_error
();
$messague
=
pcntl_strerror
(
$errno
);
fwrite
(
STDERR
,
'pcntl_wait failed with errno '
.
$errno
.
': '
.
$messague
.
PHP_EOL
);
}
The above example will output something similar to:
pcntl_wait failed with errno 10: No child processses