Home > Backend Development > PHP Problem > How to set up php function chmod

How to set up php function chmod

藏色散人
Release: 2023-03-08 10:28:01
Original
2285 people have browsed it

How to set the php function chmod: First create a PHP sample file; then use the syntax "chmod("test.txt",0600);" to set the permissions of the specified file to be readable and writable by the owner, and by others. Just do it without any permissions.

How to set up php function chmod

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

chmod() function changes the file mode.

Returns TRUE if successful, otherwise returns FALSE.

Syntax

chmod(file,mode)
Copy after login

Parameters

file Required. Specifies the documents to be checked.

mode

Optional. Specify new permissions.

The mode parameter consists of 4 numbers:

The first number is always 0

The second number specifies the owner's permissions

The second The first number specifies the permissions of the user group to which the owner belongs

The fourth number specifies the permissions of everyone else

Possible values ​​(if you need to set multiple permissions, please adjust the numbers below Total):

1 - Execute permission

2 - Write permission

4 - Read permission

Example

<?php
// 所有者可读写,其他人没有任何权限
chmod("test.txt",0600);
// 所有者可读写,其他人可读
chmod("test.txt",0644);
// 所有者有所有权限,其他所有人可读和执行
chmod("test.txt",0755);
// 所有者有所有权限,所有者所在的组可读
chmod("test.txt",0740);
?>
Copy after login

[Recommended learning : "PHP Video Tutorial"]

The above is the detailed content of How to set up php function chmod. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template