public static function putContents(string $filename, $data, bool $override = false)
    {
        $dirname = dirname($filename);
        if (!file_exists($dirname)) {
            mkdir($dirname, 0700, true);
        }
        if (!file_exists($filename) || $override) {
            $result = file_put_contents($filename, $data);
        } else {
            throw new \Exception("{$filename} is already exists");
        }
        return $result;
    }
public static function putContents(string $filename, $data, bool $override = false)
    {
        $dirname = dirname($filename);
        if (!file_exists($dirname)) {
            mkdir($dirname, 0700, true);
        }
        if (!file_exists($filename) || $override) {
            $result = file_put_contents($filename, $data);
        } else {
            throw new \Exception("{$filename} is already exists");
        }
        return $result;
    }
public static function putContents ( string $ filename , $ data , bool $ override = false ) { $ dirname = dirname ( $ filename ) ; if ( ! file_exists ( $ dirname ) ) { mkdir ( $ dirname , 0700 , true ) ; } if ( ! file_exists ( $ filename ) || $ override ) { $ result = file_put_contents ( $ filename , $ data ) ; } else { throw new \ Exception ( "{$filename} is already exists" ) ; } return $ result ; }
mkdir and put file
@param  string   $filename output file name
@param  mixed    $data contents data
@param  bool     $override if a file already exists, save the data
@throws \Exception
@return mixed if successed, return bytes. if failed, return false
mkdir and put file