
如何使用浏览器检查元素工具
win_is_writable ( $path )
win_is_writable: 这个函数用来检查一个文件或目录在Windows系统中是否可写。它需要一个参数–$path–它是要检查的文件或目录的路径。
解决is_writable()函数中的Windows bug
PHP在确定一个目录是否可写时与Windows的ACL有问题,这个方法通过检查打开文件的权限来解决,而不是依靠PHP来解释操作系统的ACL。
function win_is_writable( $path ) { if ( '/' === $path[ strlen( $path ) - 1 ] ) { // If it looks like a directory, check a random file within the directory. return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp' ); } elseif ( is_dir( $path ) ) { // If it's a directory (and not a file), check a random file within the directory. return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); } // Check tmp file for read/write capabilities. $should_delete_tmp_file = ! file_exists( $path ); $f = @fopen( $path, 'a' ); if ( false === $f ) { return false; } fclose( $f ); if ( $should_delete_tmp_file ) { unlink( $path ); } return true; }