How to check if a file could be written in PHP?

Is there a way to check if a write to a file was successful? I need a method to get the end of a write operation. If so, to call the callback function.

+5
source share
1 answer

fwrite () returns the number of bytes written, or FALSE on error.

Check if fwrite () returns false and you will know that the write was successful. Be careful when using the comparison operator ===instead of the operator ==when checking if the return value is false.

You can use filemtime()to get the latest file modification time.

+9
source

All Articles