php-src icon indicating copy to clipboard operation
php-src copied to clipboard

file_put_contents() doesn't create a file, if $data is null or its length is 0

Open Grakou opened this issue 4 years ago • 3 comments

From manual page: https://php.net/function.file-put-contents


Grakou avatar Dec 09 '21 12:12 Grakou

That would rather be an implementation bug, but it works for me:

php > var_dump(file_exists("foo"));
bool(false)
php > var_dump(file_put_contents("foo", ""));
int(0)
php > var_dump(file_exists("foo"));
bool(true)

Can you please detail in which environment/circumstances that doesn't work for you?

cmb69 avatar Dec 09 '21 12:12 cmb69

I've tried the same above thing as @cmb69 did, and I get the same result. I'm running on PHP v7.4.24 (so considering it must be working on above versions) I hope this will be helpful feedback.

AdiechaHK avatar Dec 17 '21 07:12 AdiechaHK

No feedback was provided. The issue is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so. Thank you.

github-actions[bot] avatar Jan 01 '22 00:01 github-actions[bot]