3v4l.org

run code in 300+ PHP versions simultaneously
<?php function html($value) { return htmlentities($value); } class Foo { function html($value) { return htmlentities($value); } } $value = '123'; $object = new Foo(); // 1 $start = microtime(true); for ($i = 1; $i <= 100000; $i++) { htmlentities($value); } $end = microtime(true); echo (int) (($end - $start) * 1000) . "\n"; // 2 $start = microtime(true); for ($i = 1; $i <= 100000; $i++) { html($value); } $end = microtime(true); echo (int) (($end - $start) * 1000) . "\n"; // 3 $start = microtime(true); for ($i = 1; $i <= 100000; $i++) { $object->html($value); } $end = microtime(true); echo (int) (($end - $start) * 1000) . "\n"; // 4 $start = microtime(true); for ($i = 1; $i <= 100000; $i++) { call_user_func('html', $value); } $end = microtime(true); echo (int) (($end - $start) * 1000) . "\n"; // 5 $start = microtime(true); for ($i = 1; $i <= 100000; $i++) { call_user_func(array($object, 'html'), $value); } $end = microtime(true); echo (int) (($end - $start) * 1000) . "\n"; // 6 $start = microtime(true); for ($i = 1; $i <= 100000; $i++) { call_user_func_array('html', array($value)); } $end = microtime(true); echo (int) (($end - $start) * 1000) . "\n"; // 7 $start = microtime(true); for ($i = 1; $i <= 100000; $i++) { call_user_func_array(array($object, 'html'), array($value)); } $end = microtime(true); echo (int) (($end - $start) * 1000) . "\n";

preferences:
51.71 ms | 402 KiB | 5 Q