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); // 2 $start = microtime(true); for ($i = 1; $i <= 100000; $i++) { html($value); } $end = microtime(true); echo (int) (($end - $start) * 1000); // 3 $start = microtime(true); for ($i = 1; $i <= 100000; $i++) { $object->html($value); } $end = microtime(true); echo (int) (($end - $start) * 1000); // 4 $start = microtime(true); for ($i = 1; $i <= 100000; $i++) { call_user_func('html', $value); } $end = microtime(true); echo (int) (($end - $start) * 1000); // 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); // 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); // 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);

preferences:
29.74 ms | 402 KiB | 5 Q