Suggest using the return value of `file_put_contents` directly and comparing against `=== false`; this is the typical way it's done in PHP.