chown

chown

chown — 改变文件的所有者

1 bool chown ( string $filename , mixed $user )

尝试将文件 filename 的所有者改成用户 user(由用户名或用户 ID 指定)。

只有超级用户可以改变文件的所有者。

参数:
filename

文件路径。

user

用户名或数字。

返回值:

成功时返回 TRUE, 或者在失败时返回 FALSE

简单的 chown() 用法:

<?php

// File name and username to use
$file_name= "foo.php";
$path = "/home/sites/php.net/public_html/sandbox/" . $file_name ;
$user_name = "root";

// Set the user
chown($path, $user_name);

// Check the result
$stat = stat($path);
print_r(posix_getpwuid($stat['uid']));

?>

输出结果:

 1 Array
 2 (
 3     [name] => root
 4     [passwd] => x
 5     [uid] => 0
 6     [gid] => 0
 7     [gecos] => root
 8     [dir] => /root
 9     [shell] => /bin/bash
10 )

get!:)

 

 

 

 

 

 

 

 

 

 
 
posted @ 2016-08-29 10:41  我要做李白  阅读(819)  评论(0编辑  收藏  举报