Skip to content

file_put_contents on string >= 2GB #15500

Closed as not planned
Closed as not planned
@GajowyJ

Description

@GajowyJ

Description

The following code:

<?php
$size = 2*1024*1024*1024;
$buf = str_repeat(' ',$size);
file_put_contents('file.out',$buf);

Resulted in this output:

PHP Notice:  file_put_contents(): Write of 2147483648 bytes failed with errno=0 No error in D:\test.php on line 4

PHP Warning:  file_put_contents(): Only -2147483648 of 2147483648 bytes written, possibly out of free disk space in D:\test.php on line 4

But I expected this output instead:

(no error message)

PHP Version

PHP 8.1.29 (cli) ZTS

Operating System

Windows 10 (64-bit)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions