Warning: Division by zero in /var/customers/webs/stc/benchmark/index.php on line 256 Test: strstr vs. strpos

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: strstr() vs. strpos()

10 character string, check if a substring exists in a defined location.

Run Again Test Menu


Unfortunately, no history for this test is available.


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

for ($j = 0; $j < 100; $j++)
	$GLOBALS['dummy2'] = strstr($GLOBALS['dummy'], '3456') != '';

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

for ($j = 0; $j < 100; $j++)
	$GLOBALS['dummy2'] = strpos($GLOBALS['dummy'], '3456') !== false;

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