定义

chown()函数更改指定文件的所有者。

 

语法

PHP chown()函数具有以下语法。

chown(file,owner)

 

参数

参数 是否必须 描述
file 需要。 要检查的文件
owner 需要。 新所有者。可以是用户名或用户ID。

 

返回

PHP chown()函数成功返回TRUE,失败返回FALSE。

 

实例

chown()尝试将文件更改为由用户拥有。成功时,返回true; 否则为false。

第二个参数可以是用户名或用户ID号。

<?php
/*
http://www.manongjc.com/article/1764.html
作者:码农教程
*/
      if (chown(\"myfile.txt\", \"tom\")) {
             print \"File owner changed.\\n\";
      } else {
            print \"File ownership change failed!\\n\";
      }
      
      chown(\"test.txt\",\"Jack\");
?>

上面的代码生成以下结果:

File ownership change failed!
收藏 打印