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 — Cambia il proprietario del file
Tenta di cambiare il proprietario del file filename
nell'utente user. Solo il superuser può cambiare il
proprietario di un file.
filenamePercorso del file.
userUn nome utente o un numero.
Example #1 Semplice utilizzo di chown()
<?php
// Nome file e nome utente da utilizzare
$file_name= "foo.php";
$path = "/home/sites/php.net/public_html/sandbox/" . $file_name ;
$user_name = "root";
// Imposta l'utente
chown($path, $user_name);
// Controlla il risultato
$stat = stat($path);
print_r(posix_getpwuid($stat['uid']));
?>Il precedente esempio visualizzerà qualcosa simile a:
Array
(
[name] => root
[passwd] => x
[uid] => 0
[gid] => 0
[gecos] => root
[dir] => /root
[shell] => /bin/bash
)
Nota: Questa funzione non opererà su file remoti perché il file che deve essere esaminato deve essere accessibile attraverso il filesysmte del server.
Nota: Su Windows, questa funzione fallisce silenziosamente se applicata su un file normale.
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');?>