is_writeable

bool is_writeable(string filename) 

Checks whether a file is writeable.

Returns:

TRUE if writeable; FALSE otherwise

Description:

Checks whether the specified file is writeable by PHP. Note that depending on how the script is executed (command line, CGI, module), the test may be performed with varying user IDs, so permissions may affect the result of the function. Safe mode restrictions are not taken into account.

Note:

The results of this function are cached. See clearstatcache() for details.

Example:

Check whether a file is writeable
$file = "testfile"; 

if(is_writeable($file)) 
{
    // open and write to file 
} 
else 
{
    echo ("Cannot write to file $file."); 
} 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.