PHP 8.3.4 Released!

SplFileInfo::getOwner

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

SplFileInfo::getOwnerファイルの所有者を取得する

説明

public SplFileInfo::getOwner(): int|false

ファイルの所有者を取得します。オーナー ID は数値形式で返されます。

パラメータ

この関数にはパラメータはありません。

戻り値

オーナー ID を数値形式で返します。 失敗時に false を返します。

エラー / 例外

エラー時に RuntimeException をスローします。

例1 SplFileInfo::getOwner() の例

<?php
$info
= new SplFileInfo('example.jpg');
echo
info->getFilename() . ' belongs to owner id ' . $info->getOwner() . "\n";
print_r(posix_getpwuid($info->getOwner()));
?>

上の例の出力は、 たとえば以下のようになります。

example.jpg belongs to user id 501
Array
(
    [name] => tom
    [passwd] => x
    [uid] => 501
    [gid] => 42
    [gecos] => Tom Cat
    [dir] => /home/tom
    [shell] => /bin/bash
)

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top