File文件 中的 chmod()函数

首页 / PHP入门教程 / File文件 中的 chmod()函数

chmod() - 语法

bool chmod ( string $filename, int $mode );

尝试将指定文件的模式更改为模式中给定的模式。

filename      -  文件路径。

无涯教程网

mode           -  请注意,不会自动将mode假定为八进制值,因此字符串(例如“ g + w”)将无法正常工作。 为了确保预期的操作,您需要在模式前加上零(0)

chmod() - 返回值

成功时返回TRUE,失败时返回FALSE。

chmod() - 示例

<?php
   //Read and write for owner, nothing for everybody else
   chmod("hello.txt", 0600);
   
   //Read and write for owner, read for everybody else
   chmod("hello.txt", 0644);
   
   //Everything for owner, read and execute for others
   chmod("hello.txt", 0755);
   
   //Everything for owner, read and execute for owner's group
   chmod("hello.txt", 0750);
?>

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

从0开始学架构 -〔李运华〕

Spring Boot与Kubernetes云原生微服务实践 -〔杨波〕

Linux内核技术实战课 -〔邵亚方〕

徐昊 · TDD项目实战70讲 -〔徐昊〕

Kubernetes入门实战课 -〔罗剑锋〕

现代React Web开发实战 -〔宋一玮〕

深入浅出可观测性 -〔翁一磊〕

超级访谈:对话毕玄 -〔毕玄〕

云原生架构与GitOps实战 -〔王炜〕

好记忆不如烂笔头。留下您的足迹吧 :)