我有一个需要将文本写入文件的控制台 PHP 应用程序。如果此文本大小超过 130999 字节,则不会写入数据:
$line = '';
for ( $i=0 ; $i<130991 ; $i++ ) {
$line .= 'i';
}
$size = mb_strlen($line, 'utf-8');
$line = "\n" . $size . " " . $line; // Adds another 8 bytes
$logLine = escapeshellarg($line);
echo shell_exec("echo {$logLine} >> data.log}");
怀疑内存限制,我将 PHP 内存限制从 128 MB 增加到 512 MB,情况没有任何变化。什么可能导致这种限制?
编辑:
更多信息:
$ xargs --show-limits
Your environment variables take up 3126 bytes
POSIX upper limit on argument length (this system): 2091978
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2088852
Size of command buffer we are actually using: 131072