Warning: Division by zero in /var/customers/webs/stc/benchmark/index.php on line 256 Test: substr($var, 5, 1) vs. isset && {5}

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: substr($var, 5, 1) vs. isset && {5}

Return the nth character of a string, substring vs string array checking.

Run Again Test Menu

Result

Unfortunately, no history for this test is available.

Code

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

for ($j = 0; $j < 100; $j++)
	$GLOBALS['dummy2'] = substr($GLOBALS['dummy'], 5, 1);

The second test, "isset {5}", was:

for ($j = 0; $j < 100; $j++)
	$GLOBALS['dummy2'] = isset($GLOBALS['dummy']{5}) ? $GLOBALS['dummy']{5} : '';

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