Chown () function example tutorial

Source: Internet
Author: User
Tags php online

Chown

(PHP 4 and PHP 5)

Chown-change the file owner

Description
Boolean chown (string $ file name, mixed $ user)
Attempt to change the owner file of an archive to the user. Only the Supervisor can change the human Archive.

Parameters

File name
File path.

User
User name or number.


Return value
Returns TRUE or FALSE.

Instance

<? Php

// File name and username to use
$ File_name = "foo. php ";
$ Path = "/home/sites/php.net/public_html/sandbox". $ file_name;
$ User_name = "root ";

// Set the user
Chown ($ path, $ user_name );

// Check the result
$ Stat = stat ($ path );
Print_r (posix_getpwuid ($ stat ['uid']);

?>
The above example will output something similar:

Array (7 ){
["Name"] =>
String (13) "php.net"
["Passwd"] =>
String (1) "x"
["Uid"] =>
Int (148864)
["Gid"] =>
Int (148910)
["Gecos"] =>
String (13) "php.net"
["Dir"] =>
String (25) "/home/sites/php.net"
["Shell"] =>
String (13) "/sbin/nologin"
}
Webmaster recommendation:

PHP online manual

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.