Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

posix_strerror

Description

The posix_strerror of POSIX for PHP retrieves the system error message associated with the given errno.

Syntax

posix_strerror(
    int $error_code
): string

Parameters

error_code

A POSIX error number, returned by posix_get_last_error(). If set to 0, then the string "Success" is returned.

Return

Returns the error message, as a string.

Examples

1 · error_code · 0

<?

$error_code = posix_get_last_error();

$return = posix_strerror($error_code);

echo $return;

?>
Success

2 · error_code · 1

<?

$process_id = 100;
$signal = SIGKILL;

posix_kill($process_id, $signal);

$error_code = posix_get_last_error();

$return = posix_strerror($error_code);

echo $return;

?>
Operation not permitted

3 · error_code · 3

<?

$process_id = 100000;
$signal = SIGKILL;

posix_kill($process_id, $signal);

$error_code = posix_get_last_error();

$return = posix_strerror($error_code);

echo $return;

?>
No such process

4 · error_code · 13

<?

$filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/txt/1.txt';
$flags = POSIX_X_OK;

posix_access($filename, $flags);

$error_code = posix_get_last_error();

$return = posix_strerror($error_code);

echo $return;

?>
Permission denied
HomeMenu