English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP chown() Function Usage and Example

PHP Filesystem Reference Manual

The chown() function can change the owner of the specified file.

Syntax

bool chown ( string filename, mixed user )

 Attempt to change the owner of the file filename to the user user (specified by username or user ID). Only superusers can change the owner of the file. This function returns true on success, otherwise false.

Online Example

<?php
   // File name and user name to be used
   $file_name=  "index.php";
   $path  =  ""/PhpProject/backup:  "  .  $file_name  ;
   $user_name  =  "root";
   //Set User
   chown($path,  $user_name);
   print_r($path);
?>

Output Result

/PhpProject/backup:  index.php

PHP Filesystem Reference Manual