downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

fileperms> <filemtime
[edit] Last updated: Fri, 17 May 2013

view this page in

fileowner

(PHP 4, PHP 5)

fileowner取得文件的所有者

说明

int fileowner ( string $filename )

取得文件的所有者。

参数

filename

文件的路径。

返回值

返回文件所有的用户 ID,如果出错则返回 FALSE。用户 ID 以数字格式返回,用 posix_getpwuid() 来将其解析为用户名。

范例

Example #1 找到文件的所有者

<?php
$filename 
'index.php';
print_r(posix_getpwuid(fileowner($filename)));
?>

错误/异常

失败时抛出E_WARNING警告。

注释

Note: 此函数的结果会被缓存。参见 clearstatcache() 以获得更多细节。

Tip

自 PHP 5.0.0 起, 此函数也用于某些 URL 包装器。请参见 支持的协议和封装协议以获得支持 stat() 系列函数功能的包装器列表。

参见



fileperms> <filemtime
[edit] Last updated: Fri, 17 May 2013
 
add a note add a note User Contributed Notes fileowner - [3 notes]
up
0
dazoe
2 years ago
Remember to use if(fileowner(...) === FALSE) instead of if(!fileowner()) or if(fileowner() == FLASE) because if the owner was "root" it would return 0.
up
0
joacorck at gmail dot com
6 years ago
This function only works if the permissions are more less than 666
up
0
Anonymous
7 years ago
Small note: the function resolves symbolic links. That is, if the link is created by user 999 and maps to a file owned by user 666, this function returns 666 :(

 
show source | credits | sitemap | contact | advertising | mirror sites