Skip to content

require() with >2GB #19542

@thomas-0816

Description

@thomas-0816

Description

The following code:

<?php

ini_set('display_errors', 1);
ini_set('memory_limit', '10G');

$fp = fopen('/tmp/test.php', 'w');
fwrite($fp, '<?php return "');
for ($i=0; $i < 2048; $i++) {
    fwrite($fp, str_repeat('#', 1024*1024));
}
fwrite($fp, '";');
fclose($fp);

$a = require '/tmp/test.php';
echo strlen($a);

Resulted in this output:

0

But I expected this output instead:

2147483664 (or similar)

PHP Version

PHP 8.4.11 (cli) (built: Aug  3 2025 08:42:03) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.11, Copyright (c), by Zend Technologies

Operating System

Ubuntu 22.04.5 LTS

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