PHP检查目录是否可写

    /**
     * 检查目录是否可写
     * @param $path
     * @return bool
     */
    private function checkWriteable($path)
    {
    
    
        try {
    
    
            !is_dir($path) && mkdir($path, 0755);
            if (!is_dir($path))
                return false;
            $fileName = $path . '/_test_write.txt';
            if ($fp = fopen($fileName, 'w')) {
    
    
                return fclose($fp) && unlink($fileName);
            }
        } catch (\Exception $e) {
    
    
        }
        return false;
    }