must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
Description
posix_access() checks whether the current process can access a file in a given way. Its $flags argument only accepts a bitmask built from POSIX_F_OK (existence), POSIX_R_OK (readable), POSIX_W_OK (writable), and POSIX_X_OK (executable).
As of PHP 8.6, passing a value with bits set outside of that set throws a ValueError, instead of forwarding an unvalidated flag value straight to the underlying access() system call.
Example
<?php
posix_access('/etc/passwd', 999);
?>
Literal Examples
- posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
Alternatives
- Build
$flagsforposix_access()only out ofPOSIX_F_OK,POSIX_R_OK,POSIX_W_OK, andPOSIX_X_OK, combined with|as needed.
Changed Behavior
This error may appear following an evolution in behavior, in previous versions. See [Previously, an out-of-range $flags value was passed through to the underlying access() call unchecked instead of being rejected.](Previously, an out-of-range $flags value was passed through to the underlying access() call unchecked instead of being rejected.)