The problem here is not the upgrade in PHP version, but the fact that it failed to actually open the file in question.
fopen returns either a resource
on success or false
on failure:
$data ="<html><table><tr><td>test</td></tr></table></html>";
// Make sure we have a / or \ between the path and the filename
$fileName = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . "test.xls";
$file = fopen($fileName,"w");
if ($file === false) {
echo "opening '$fileName' failed";
exit;
}
if (fwrite($file, $data)){
echo $fileName;
}
So you need to figure out why it can't open it in the first place. Perhaps a problem with your $path
? Does it end with a \
(or /
on linux)? Does the actual path exist. Is it actually set (given that it wasn't added to your code here it might just as well be empty as far as we know)