Home:ALL Converter>fwrite() expects parameter 1 to be resource and fclose() expects parameter 1 to be resource

fwrite() expects parameter 1 to be resource and fclose() expects parameter 1 to be resource

Ask Time:2017-11-29T22:52:53         Author:Mamunur Rashid

Json Formatter

private function WriteFile($file,$mode,$content){
    $handle = fopen($file, $mode);
    fwrite($handle, $content);
    fclose($handle);
}

this is my code and giving me the error

fclose() expects parameter 1 to be resource, boolean given in and fwrite() expects parameter 1 to be resource, boolean given in directory

Author:Mamunur Rashid,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/47555611/fwrite-expects-parameter-1-to-be-resource-and-fclose-expects-parameter-1-to
yy