3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface IPlugin { public function set_hooks(); public function plugin_info(); public function deactivate(); } function __autoload($class) { include(getcwd() . "/plugins/" . ucfirst($class) . ".php"); } /* Static class responsible for every plugin */ class Plugins { private static $plugins = array(); private static $hooks = array(); private static $plugin_count = 0; private static $hook_count = 0; public function __construct() { $dir = opendir(getcwd() . '/plugins'); while (false !== ($filename = readdir($dir))) { if (stripos($filename, '.php') === false || strcmp($filename, 'IPlugin.php') == 0) continue; $name = str_replace('.php', '', $filename); array_push(self::$plugins, array( 'name' => $name, 'filename' => $filename, 'filepath' => getcwd().'/plugins/'.$filename ) ); self::$plugin_count++; self::add_hook($name, true); } } public static function add_hook($name, $activate) { $hooks = self::$hooks; $length = count($hooks); for ($i = 0; $i < $length; $i++) if (in_array($name, $hooks[$i]) == true) { if ($hooks[$i]['name'] !== $name) continue; self::$hooks[$i]['activate'] = 1; self::$hook_count++; return; } array_push(self::$hooks, array( 'name' => $name, 'activate' => $activate ) ); self::$hook_count++; } public static function remove_hook($name) { $hooks = self::$hooks; $length = count($hooks); $name = str_replace('.php', '', $name); for ($i = 0; $i < $length; $i++) { if ($hooks[$i]['name'] !== $name) continue; self::$hook_count--; self::$hooks[$i]['activate'] = 0; } } public static function run_hooks($hook) { $plugins = self::$plugins; $hooks = self::$hooks; for ($i = 0; $i < count($hooks); $i++) { $plugin = self::getPluginObject($hooks[$i]['name']); if ($hooks[$i]['activate'] == 0) { $hook_defunc = 'deactivate_' . $hook; $func = is_callable(array($plugin, $hook_defunc)); if (!$func) $plugin->deactivate(); else $plugin->$hook_defunc(); continue; } $plugin_hooks = count($plugin->set_hooks()); for ($i2 = 0; $i2 < $plugin_hooks; $i2++) if (strcasecmp($plugin_hooks[$i2], $hook) != 0) continue; $hook_func = 'activate_' . $hook; $func = is_callable(array($plugin, $hook_func)); if (!$func) $plugin->deactivate(); else $plugin->$hook_func(); } } public static function getPluginObject($name) { $plugins = self::$plugins; $plugin_count = count($plugins); for ($i = 0; $i < $plugin_count; $i++) { if ($plugins[$i]['name'] !== $name) continue; return new $plugins[$i]['name'](); } return null; } public static function getPluginCount() { return self::$plugin_count; } public static function getHookCount() { return self::$hook_count; } public static function get_plugins() { return self::$plugins; } public static function get_hooks() { return self::$hooks; } } class TestPlugin implements IPlugin { public function set_hooks() { return array( 'index_bottom', 'index_content' ); } public function plugin_info() { return array( 'name' => 'Test Plugin', 'version' => 1.1 ); } public function activate_index_bottom() { echo '<p>This will activate if the index_bottom hook is used</p>'; } public function deactivate_index_bottom() { echo 'DEACTIVATE INDEX BOTTOM'; } public function activate_index_content() { echo '<a href="lol.php" alt="">lolfags</a>'; } public function deactivate_index_content() { echo 'DEACTIVATE'; } // invoked if other hook functions fail for any reason public function deactivate() { echo '<h1>Plugin system broken!!?!?!?</h1>'; } } echo '<html><head></head><body><p>blabla</p>'; $plugins = new Plugins(); $plugins->run_hooks('index_content'); echo '<hr />'; $plugins->run_hooks('index_bottom'); echo '<p>woot</p></body></html>';

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0070.01318.43
8.3.50.0110.01121.93
8.3.40.0060.01518.67
8.3.30.0040.01218.92
8.3.20.0040.00420.33
8.3.10.0050.00322.05
8.3.00.0040.00422.43
8.2.180.0100.01016.75
8.2.170.0120.00322.96
8.2.160.0070.00721.01
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.01126.16
8.2.120.0000.00719.79
8.2.110.0080.00417.50
8.1.280.0070.01425.92
8.1.270.0040.00422.14
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00618.84
8.0.120.0070.00113.23
8.0.110.0060.00313.22
8.0.100.0020.00713.24
8.0.90.0050.00313.23
8.0.80.0030.00513.26
8.0.70.0010.00813.29
8.0.60.0060.00313.26
8.0.50.0080.00113.29
8.0.30.0000.00913.26
8.0.20.0060.00513.29
8.0.10.0100.00213.44
8.0.00.0030.00313.41
7.4.250.0080.00413.47
7.4.240.0090.00213.42
7.4.230.0090.00313.47
7.4.220.0060.00413.39
7.4.210.0080.00313.39
7.4.200.0090.00113.33
7.4.190.0040.00713.35
7.4.180.0080.00313.18
7.4.160.0080.00513.51
7.4.150.0100.00513.35
7.4.140.0150.00213.36
7.4.130.0040.00913.42
7.4.120.0060.00613.34
7.4.110.0060.00613.26
7.4.100.0080.00413.49
7.4.90.0100.00413.42
7.4.80.0090.00614.35
7.4.70.0160.01614.26
7.4.60.0260.01015.38
7.4.50.0110.00815.27
7.4.40.0150.01216.42
7.4.30.0100.00714.88
7.4.20.0120.00614.82
7.4.10.0220.00914.87
7.4.00.0090.01014.92
7.3.320.0060.00813.40
7.3.310.0110.00413.39
7.3.300.0100.00313.49
7.3.290.0130.00013.39
7.3.280.0080.00613.37
7.3.270.0030.01413.36
7.3.260.0100.00413.54
7.3.250.0090.00213.38
7.3.240.0120.00613.39
7.3.230.0080.00513.44
7.3.220.0090.00413.18
7.3.210.0090.00213.28
7.3.200.0050.00914.32
7.3.190.0180.00914.16
7.3.180.0270.00815.15
7.3.170.0140.01114.79
7.3.160.0130.01414.74
7.3.150.0140.01014.75
7.3.140.0090.00414.79
7.3.130.0100.00614.86
7.3.120.0310.01514.85
7.3.110.0210.01314.68
7.3.100.0170.01014.70
7.3.90.0140.00614.96
7.3.80.0060.01314.85
7.3.70.0100.00714.74
7.3.60.0090.00714.81
7.3.50.0250.00714.69
7.3.40.0090.00514.78
7.3.30.0100.00614.81
7.3.20.0100.00915.61
7.3.10.0140.01015.76
7.3.00.0110.00615.62
7.2.340.0100.00313.43
7.2.330.0090.00513.39
7.2.320.0150.00614.45
7.2.310.0100.01014.92
7.2.300.0110.00714.98
7.2.290.0090.00815.07
7.2.280.0180.00515.04
7.2.270.0100.00814.92
7.2.260.0110.00714.99
7.2.250.0150.00614.96
7.2.240.0080.01315.00
7.2.230.0110.01114.95
7.2.220.0110.00615.10
7.2.210.0130.00615.03
7.2.200.0110.00615.00
7.2.190.0110.01014.96
7.2.180.0170.00715.02
7.2.170.0160.00315.02
7.2.160.0130.00515.04
7.2.150.0130.00915.87
7.2.140.0150.00715.92
7.2.130.0130.01015.93
7.2.120.0110.00815.88
7.2.110.0170.00715.98
7.2.100.0120.00615.99
7.2.90.0190.00915.97
7.2.80.0110.01115.95
7.2.70.0210.00615.85
7.2.60.0120.00715.94
7.2.50.0150.00815.90
7.2.40.0110.00615.99
7.2.30.0190.00915.90
7.2.20.0180.01515.96
7.2.10.0140.01016.02
7.2.00.0150.00915.86
7.1.330.0080.00914.90
7.1.320.0110.00514.88
7.1.310.0090.00714.84
7.1.300.0140.00614.97
7.1.290.0110.00814.86
7.1.280.0140.00714.84
7.1.270.0080.00814.86
7.1.260.0080.01014.93
7.1.250.0080.01214.77
7.1.240.0140.00714.79
7.1.230.0160.01214.94
7.1.220.0120.01014.86
7.1.210.0210.00914.89
7.1.200.0110.01014.91
7.1.190.0200.00814.90
7.1.180.0130.01014.76
7.1.170.0130.01114.88
7.1.160.0170.00814.80
7.1.150.0170.00714.77
7.1.140.0100.00814.81
7.1.130.0140.00714.75
7.1.120.0100.01114.78
7.1.110.0160.01014.78
7.1.100.0130.01114.77
7.1.90.0150.00814.90
7.1.80.0250.00914.90
7.1.70.0230.00614.84
7.1.60.0150.01214.92
7.1.50.0150.01014.87
7.1.40.0280.00514.92
7.1.30.0140.00614.94
7.1.20.0110.00714.84
7.1.10.0090.01314.84
7.1.00.0160.00914.78
7.0.330.0130.00614.71
7.0.320.0120.00514.61
7.0.310.0140.00914.77
7.0.300.0110.00614.71
7.0.290.0120.01014.63
7.0.280.0130.01014.66
7.0.270.0140.01014.74
7.0.260.0130.00814.67
7.0.250.0140.00614.75
7.0.240.0130.01014.82
7.0.230.0150.00714.74
7.0.220.0190.01214.73
7.0.210.0190.00914.71
7.0.200.0130.00914.77
7.0.190.0090.00914.69
7.0.180.0160.00614.77
7.0.170.0180.00714.70
7.0.160.0170.00614.64
7.0.150.0100.00814.60
7.0.140.0130.00814.63
7.0.130.0110.00914.70
7.0.120.0090.00714.70
7.0.110.0070.00814.60
7.0.100.0100.00614.66
7.0.90.0090.00914.66
7.0.80.0100.00614.44
7.0.70.0190.00614.49
7.0.60.0140.00414.45
7.0.50.0070.01314.39
7.0.40.0130.00814.56
7.0.30.0130.00514.44
7.0.20.0090.00314.05
7.0.10.0090.00614.24
7.0.00.0050.00814.08
5.6.400.0200.01615.85
5.6.390.0140.01915.87
5.6.380.0220.02016.04
5.6.370.0070.01815.65
5.6.360.0170.01515.97
5.6.350.0090.00915.89
5.6.340.0280.01915.89
5.6.330.0180.01215.83
5.6.320.0140.01615.95
5.6.310.0240.01515.98
5.6.300.0150.02215.85
5.6.290.0270.00615.88
5.6.280.0090.01515.92
5.6.270.0120.01215.84
5.6.260.0120.01315.82
5.6.250.0120.01715.78
5.6.240.0200.01215.92
5.6.230.0170.00915.74
5.6.220.0160.00815.82
5.6.210.0060.01715.67
5.6.200.0160.00915.92
5.6.190.0210.01815.77
5.5.380.0100.01515.88
5.5.370.0300.01815.96
5.5.360.0270.02015.70
5.5.350.0290.00415.79
5.5.340.0190.00915.88
5.5.330.0110.01115.70
5.4.270.0130.07718.89
5.4.260.0300.08719.08
5.4.250.0170.07718.92
5.4.240.0570.06019.11
5.4.230.0030.08319.25
5.4.220.0170.05318.95
5.4.210.0000.06318.92
5.4.200.0600.04019.07
5.4.190.0100.08018.98
5.4.180.0100.05719.25
5.4.170.0500.03319.05
5.4.160.0200.04019.05
5.4.150.0030.06319.13
5.4.140.0170.05316.55
5.4.130.0100.05016.45
5.4.120.0070.05316.43
5.4.110.0270.03316.31
5.4.100.0470.04016.48
5.4.90.0070.06016.54
5.4.80.0130.06016.48
5.4.70.0000.06316.53
5.4.60.0070.05316.34
5.4.50.0170.04716.31
5.4.40.0030.05316.21
5.4.30.0130.06716.48
5.4.20.0100.05716.53
5.4.10.0200.04716.34
5.4.00.0100.04715.82
5.3.280.0130.06014.50
5.3.270.0200.04314.53
5.3.260.0130.05714.50
5.3.250.0600.06014.49
5.3.240.0130.05014.52
5.3.230.0270.06714.50
5.3.220.0300.04714.36
5.3.210.0330.04014.43
5.3.200.0300.04314.45
5.3.190.0370.03714.43
5.3.180.0100.05014.48
5.3.170.0430.04314.53
5.3.160.0470.04014.38
5.3.150.0170.05714.50
5.3.140.0330.04014.43
5.3.130.0070.05714.43
5.3.120.0400.03714.52
5.3.110.0170.04714.42
5.3.100.0400.03713.93
5.3.90.0100.05013.92
5.3.80.0370.03713.79
5.3.70.0200.06313.72
5.3.60.0100.06013.83
5.3.50.0030.05713.65
5.3.40.0170.05313.81
5.3.30.0130.04713.77
5.3.20.0030.05713.52
5.3.10.0100.06313.55
5.3.00.0170.05013.56

preferences:
46.98 ms | 401 KiB | 5 Q