If chown is filled with a variable ( chown ("myfile", $uid) the uid will be looked up through pwget_uid.So if you need to set a non existing uid use inval($uid).(PHP 4, PHP 5, PHP 7, PHP 8)
chown — Dosyanın sahibini değiştirir
dosyaismi ile belirtilen dosyanın sahibini
kullanıcı yapmaya çalışır. Bu değişikliği sadece
root yapabilir.
dosyaismiDosya yolu.
kullanıcıKullanıcı ismi veya numarası.
Örnek 1 - chown() örneği
<?php
// Kullanılacak dosya ve kullanıcı ismi
$dosya_ismi= "foo.php";
$yol = "/home/sites/php.net/public_html/sandbox/" . $dosya_ismi ;
$kull_ismi = "root";
// Kullanıcıyı değiştirelim
chown($yol, $kull_ismi);
// sonucu sınayalım
$durum = stat($yol);
print_r(posix_getpwuid($stat['uid']));
?>Yukarıdaki örnek şuna benzer bir çıktı üretir:
Array
(
[name] => root
[passwd] => x
[uid] => 0
[gid] => 0
[gecos] => root
[dir] => /root
[shell] => /bin/bash
)
Bilginize: Dosyaların sunucunun dosya sistemi üzerinden erişilebilir olması gerektiğinden bu işlev uzak dosyalar üzerinde çalışmayacaktır.
Bilginize: Windows'ta, bu işlev normal bir dosyaya uygulandığında sessizce başarısız olur.
If chown is filled with a variable ( chown ("myfile", $uid) the uid will be looked up through pwget_uid.So if you need to set a non existing uid use inval($uid).It may be worth making explicitly clear that, while the shell's `chown` command allows both user and group to be set in one system call like this `chown username:groupname filename`, PHP's version unfortunately does not: <?php// This will not work. chown($filename, 'username:groupname');// You have to use two separate calls.chown($filename, 'username');chgrp($filename, 'groupname');?>