Home >Backend Development >PHP Tutorial >A brief analysis of the PHP implementation of is_writable_PHP tutorial

A brief analysis of the PHP implementation of is_writable_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:06:021467browse

The following functions can be used to replace PHP's built-in is_writable function

Copy code The code is as follows:

//Can be used to replace PHP's built-in is_writable function
function isWritable($filename){
if(preg_match('//$/',$filename)){
$tmp_file=sprintf('%s%s.tmp',$filename ,uniqid(mt_rand()));
                                                                                                                                          return isWritable($tmp_file);
$fp=@fopen($filename,'r+');
if($fp){
fclose($fp);
return true;
}
else{
                                                               ; fclose( $fp);
unlink($filename);
return true;
}
else{
return false;
}
}
}





http://www.bkjia.com/PHPjc/327640.html

www.bkjia.com

true
http: //www.bkjia.com/PHPjc/327640.html

TechArticleThe following functions can be used to replace php’s built-in is_writable function. Copy the code. The code is as follows: //Can be used to replace php’s built-in is_writable Function function isWritable($filename){ if(preg_match('//...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn