Summery Summery
Converts *nix-style file permissions to a octal number.
Syntax Syntax
Description Description
Converts ‘-rw-r–r–‘ to 0644 From "info at rvgate dot nl"’s comment on the PHP documentation for chmod()
Parameters Parameters
- $mode
-
(Required) string The *nix-style file permission.
Return Return
(int) octal representation
Source Source
File: wp-admin/includes/class-wp-filesystem-base.php
}
/**
* Converts *nix-style file permissions to a octal number.
*
* Converts '-rw-r--r--' to 0644
* From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
*
* @link https://www.php.net/manual/en/function.chmod.php#49614
*
* @since 2.5.0
*
* @param string $mode string The *nix-style file permission.
* @return int octal representation
*/
public function getnumchmodfromh( $mode ) {
$realmode = '';
$legal = array( '', 'w', 'r', 'x', '-' );
$attarray = preg_split( '//', $mode );
for ( $i = 0, $c = count( $attarray ); $i < $c; $i++ ) {
$key = array_search( $attarray[ $i ], $legal, true );
if ( $key ) {
$realmode .= $legal[ $key ];
}
}
Advertisement
Changelog Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |