How to set file permissions in php

WJ
Release: 2023-03-01 10:18:02
Original
3289 people have browsed it

How to set file permissions in php

The way to set file permissions in php is:

Use the chmod function
The mode parameter contains three octal numbers, which are specified in order. The owner, the owner's group, and access restrictions for everyone. Each part can be calculated by adding the required permissions. The number 1 makes the file executable, the number 2 makes the file writable, and the number 4 makes the file readable. Add these numbers to specify the required permissions.

<?php
// Read and write for owner, nothing for everybody else
chmod("/somedir/somefile", 0600);
// Read and write for owner, read for everybody else
chmod("/somedir/somefile", 0644);
// Everything for owner, read and execute for others
chmod("/somedir/somefile", 0755);
// Everything for owner, read and execute for owner&#39;s group
chmod("/somedir/somefile", 0750);
?>
Copy after login

Related references:php中文网

The above is the detailed content of How to set file permissions in php. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template