Warning: Division by zero in /var/customers/webs/stc/benchmark/index.php on line 256 Test: file vs. file_get_contents (array)

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: file() vs. file_get_contents() (array)

Run Again Test Menu


Unfortunately, no history for this test is available.


The first test, "file()", was:

$lines = file('supplement/dummy.inc');
foreach ($lines as $line)
	$GLOBALS['dummy2'] = rtrim($line);

The second test, "file_get_contents()", was:

$lines = explode("\n", str_replace(array("\r\n", "\r"), "\n", file_get_contents('supplement/dummy.inc')));
foreach ($lines as $line)
	$GLOBALS['dummy2'] = $line;

Running: Linux (x86_64:1 GB) PHP (7.2.34-18+ubuntu16.04.1+deb.sury.org+1)