- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
chown() function in PHP
The chown() function changes the file owner. Set a new owner for any file. This function won’t work for remote files.
Syntax
chown($file_path, $user );
Parameters
file_path − Set the path of file or directory to be checked. Required.
user − Set the new owner name or id.
Return
The chown() method returns.
- True, on success
- False, on failure
Example
The following is an example that set new owner for file “demo.txt”.
<?php // set new owner $file_path = "demo.php"; $user = "jack"; chown($file_path, $user); ?>
Let us see another example, wherein a new user is set for file “new.txt”.
Example
<?php // set new owner chown("new.txt","amit"); ?>
Advertisements