目录

PHP chmod() 函数

❮ PHP 文件系统参考

示例

更改 "test.txt" 文件的权限:

<?php
// Read and write for owner, nothing for everybody else
chmod("test.txt",0600);

// Read and write for owner, read for everybody else
chmod("test.txt",0644);

// Everything for owner, read and execute for everybody else
chmod("test.txt",0755);

// Everything for owner, read for owner's group
chmod("test.txt",0740);
?>


定义和用法

chmod() 函数更改指定文件的权限。

语法

chmod( file, mode)

参数值

Parameter Description
file Required. Specifies the path to the file
mode Required. Specifies the new permissions.

The mode parameter consists of four numbers:

  • The first number is always zero
  • The second number specifies permissions for the owner
  • The third number specifies permissions for the owner's user group
  • The fourth number specifies permissions for everybody else

Possible values (to set multiple permissions, add up the following numbers):

  • 1 = execute permissions
  • 2 = write permissions
  • 4 = read permissions


技术细节

返回值: TRUE 成功,FALSE 失败
PHP 版本: 4.0+

❮ PHP 文件系统参考