- 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
is_writable() function in PHP
The is_writable() function checks whether a file is writeable. It returns TRUE if the file exists and is writeable.
Syntax
is_writable(file_path)
Parameters
file_path − The path of the file to be checked.
Return
The is_writable() function returns TRUE if the file exists and is writeable.
Example
<?php $file = "one.txt"; if(is_writable($file)) { echo ("File is writeable!"); } else { echo ("File is not writeable!"); } ?>
Output
File is not writeable!
Let us see another example.
Example
<?php $file_permissions = fileperms("two.txt"); $res = sprintf("%o", $file_permissions); $file = "two.txt"; if(is_writable($file)) { echo ("File is writeable!"); echo(“Permission = $res”); } else { echo ("File is not writeable!"); echo(“Permission = $res”); } ?>
Output
File is writeable! Permission: 0777
Advertisements