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

search for in the

fileperms> <filemtime
[edit] Last updated: Fri, 10 Feb 2012

view this page in

fileowner

(PHP 4, PHP 5)

fileownerファイルの所有者を取得する

説明

int fileowner ( string $filename )

ファイルの所有者を取得します。

パラメータ

filename

ファイルへのパス。

返り値

ファイルの所有者のユーザ ID を返し、失敗した場合に FALSE を返します。 ユーザ ID は数値で返されます。ユーザ名に変換するには posix_getpwuid() を使用してください。

例1 ファイルの所有者の取得

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

エラー / 例外

失敗したときは E_WARNING が発生します。

注意

注意: この関数の結果は キャッシュされます。詳細は、clearstatcache() を参照してください。

ヒント

PHP 5.0.0 以降、この関数は、 何らかの URL ラッパーと組合せて使用することができます。 どのラッパーが stat() ファミリーをサポートしているかを調べるには サポートするプロトコル/ラッパー を参照してください。

参考

  • filegroup() - ファイルのグループを取得する
  • stat() - ファイルに関する情報を取得する
  • posix_getpwuid() - 指定 ID のユーザに関する情報を返す



fileperms> <filemtime
[edit] Last updated: Fri, 10 Feb 2012
 
add a note add a note User Contributed Notes fileowner
dazoe 28-Jun-2010 04:21
Remember to use if(fileowner(...) === FALSE) instead of if(!fileowner()) or if(fileowner() == FLASE) because if the owner was "root" it would return 0.
joacorck at gmail dot com 26-Feb-2007 02:20
This function only works if the permissions are more less than 666
29-Jan-2006 01:58
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 | stats | sitemap | contact | advertising | mirror sites