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
Release: 2016-07-21 15:06:02
Original
1464 people have browsed it

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('//...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template