3v4l.org

run code in 300+ PHP versions simultaneously
<?php #CreatedBy;Aaron;11OCT2014;Odin-Framework class odin extends _thunderbolt { /* Odin is a new PHP Framework which is a hybrid between functional & object oriented programming. It aims to create a system that will take advantage of both programming styles, giving the programmer both power and preformance. This can be used to create a stand-alone application, or as a simple way to dynamically load your own php libraries/classes) into another application either as its being built or after it was already completed. From here on, we will be reffering to all php libraries/classes as 'bolts'. */ #reserved names that are not allowed to be loaded. function __construct($my_dir,$conf_dir='_conf') { #load the default configs for $odin. require_once("$my_dir/$conf_dir/odin.php"); $this->conf = new conf_odin($my_dir); $this->_odin_set_conf( array( 'paths' => array( 'lib' => $this->conf->paths->bolts, 'conf' => $this->conf->paths->confs, ), 'prefix' => 'bolt_', # 'reserved' => array('load_bolt'=>TRUE,'bolts'=>TRUE,'odin'=>TRUE,'reserved_names'=>TRUE), ) ); } #return bool if the method exists inside of a specific bolt. Also auto-loads the bolt. function bolt_method_exists($bolt,$method) { return method_exists($this->{$bolt},$method); } } /* The methods in this class (and the class itself) are named weird to avoid class-name & function-name overlaps. This is intended to be extended by things and have its methods never actually called by the developer, except when s/he calls the _odin_set_conf() in their construct, but I'm envisioning that as being a copy/paste for them. */ class _thunderbolt { /* Usage: On the class you want to use autoloading with, just do "class {class_name} extends _thunderbolt". Then in your __construct() method, tun this code, with your own configuration typed in: $this->_odin_set_conf( array( 'paths' => array( 'lib' => $paths->bricks, 'conf' => $paths->bricks, ), 'prefix' => 'mortar_'.$class_name.'_', 'folder_name' => TRUE, 'reserved' => array('load_bolt'=>TRUE,'bolts'=>TRUE,'odin'=>TRUE,'reserved_names'=>TRUE), ) ); */ var $_odin_reserved_vars; var $_odin_paths; var $_append_folder_name; var $_prefix; function __get($name) { switch(TRUE) { #block reserved names. case (isset($this->_odin_reserved_vars[$name])): return FALSE; break; #if the name is already set, return it case (isset($this->{$name})): #attempt to load the name. case ($this->_odin_autoload($name)): return $this->{$name}; break; break; } return FALSE; } function _odin_set_conf($o) { #set paths? if(isset($o['paths'])) { #clear (or make) the _odin_paths variable $this->_odin_paths = new stdClass(); #set the conf path (if there is one) if(isset($o['paths']['conf'])) { $this->_odin_paths->conf = $o['paths']['conf']; } #set the lib path (if there is one). Note: If this never gets a lib path, this will never load libraries (classes) of code. if(isset($o['paths']['lib'])) { $this->_odin_paths->lib = $o['paths']['lib']; } } /* This option is a boolean that decides how the paths works: TRUE = append the $name as a folder to the end of the lib & configs path, and the config files are loaded from the conf dir like this: libraries ~/$o[paths][lib]/$name/$name.php configs ~/$o[paths][conf]/$name/conf.php FALSE = does not append $name as a folder libraries ~/$o[paths][lib]/$name.php configs ~/$o[paths][conf]/$name.php */ if(isset($o['folder_name'])) { $this->_append_folder_name = $o['folder_name']; } #Whatever prefix you put on your classes that are auto-loaded, if any.. and you really should have one, but its not required if(isset($o['prefix'])) { $this->_prefix = $o['prefix']; } #set the reserved class-names, if its keys are not strings, array_flip it so we can use the more efficient is_set() on our checks. if(isset($o['reserved'])) { $this->_odin_reserved_vars = (isset($o['reserved'][0])?array_flip($o['reserved']):$o['reserved']); } return TRUE; } function _odin_autoload($name) { #get a local cache of the load settings $paths = $this->_odin_paths; $append = $this->_append_folder_name; $class_prefix = $this->_prefix; #setup paths ahead of time $lib_path = $paths->lib.$name.($append?(is_string($append)?"/$append/$name":"/$name"):'').'.php'; if(isset($paths->conf) && $paths->conf) { $conf_path = $paths->conf.$name.($append?(is_string($append)?"/$append":"/conf"):'').'.php'; } #return false if this file does not exist. if(!file_exists($lib_path)) { return FALSE; } #load the bolt file require_once($lib_path); /* set $conf & then load this bolt's config file, if it exists. note: if you do have a bolt config file, then whatever you set into a $conf variable in that php script will be sent into your bolt file */ $conf = NULL; if(isset($conf_path) && file_exists($conf_path)) { include($conf_path); } #get the class name for this bolt. $cname = $class_prefix.$name; #initate the new library. $this->{$name} = new $cname($conf); return TRUE; } }

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.40.0160.00018.79
8.3.30.0000.01419.09
8.3.20.0040.00420.25
8.3.10.0050.00323.65
8.3.00.0080.00019.13
8.2.170.0110.00422.96
8.2.160.0130.00720.37
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00422.27
8.2.110.0000.00822.25
8.2.100.0100.00317.63
8.2.90.0040.00419.08
8.2.80.0050.00317.97
8.2.70.0060.00317.38
8.2.60.0050.00317.93
8.2.50.0040.00418.07
8.2.40.0060.00318.22
8.2.30.0030.00618.09
8.2.20.0040.00417.63
8.2.10.0000.00718.10
8.2.00.0030.00517.53
8.1.270.0030.00523.82
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0030.00623.93
8.1.230.0110.00019.15
8.1.220.0040.00417.74
8.1.210.0090.00018.77
8.1.200.0040.00417.22
8.1.190.0040.00417.25
8.1.180.0080.00018.10
8.1.170.0090.00020.38
8.1.160.0080.00022.04
8.1.150.0040.00418.78
8.1.140.0060.00317.43
8.1.130.0040.00417.84
8.1.120.0000.00717.47
8.1.110.0030.00517.39
8.1.100.0040.00417.33
8.1.90.0000.00717.36
8.1.80.0000.00717.30
8.1.70.0040.00417.45
8.1.60.0030.00617.54
8.1.50.0030.00517.54
8.1.40.0030.00517.34
8.1.30.0040.00417.64
8.1.20.0050.00317.52
8.1.10.0050.00317.32
8.1.00.0040.00417.36
8.0.300.0040.00418.77
8.0.290.0000.00816.75
8.0.280.0000.00718.30
8.0.270.0070.00016.75
8.0.260.0040.00417.23
8.0.250.0060.00016.91
8.0.240.0050.00316.82
8.0.230.0000.00716.83
8.0.220.0000.00716.86
8.0.210.0070.00016.88
8.0.200.0000.00716.82
8.0.190.0030.00516.80
8.0.180.0040.00416.81
8.0.170.0000.00816.89
8.0.160.0000.00716.83
8.0.150.0060.00316.79
8.0.140.0040.00416.75
8.0.130.0000.00513.27
8.0.120.0040.00416.79
8.0.110.0050.00216.84
8.0.100.0030.00516.87
8.0.90.0000.00816.89
8.0.80.0070.00716.86
8.0.70.0030.00616.81
8.0.60.0040.00416.86
8.0.50.0070.00016.91
8.0.30.0090.01317.04
8.0.20.0070.01817.40
8.0.10.0000.00716.98
8.0.00.0110.01216.70
7.4.330.0050.00015.02
7.4.320.0030.00316.50
7.4.300.0070.00016.56
7.4.290.0000.00716.48
7.4.280.0030.00916.57
7.4.270.0000.00716.55
7.4.260.0000.00616.45
7.4.250.0040.00416.53
7.4.240.0050.00216.43
7.4.230.0000.00716.36
7.4.220.0090.01616.65
7.4.210.0100.00916.61
7.4.200.0020.00516.39
7.4.160.0030.01216.50
7.4.150.0090.00917.40
7.4.140.0180.00317.86
7.4.130.0080.01016.44
7.4.120.0070.01016.46
7.4.110.0070.01016.40
7.4.100.0100.01016.26
7.4.90.0150.00316.51
7.4.80.0070.01019.39
7.4.70.0070.01116.41
7.4.60.0040.01916.46
7.4.50.0000.00816.38
7.4.40.0080.00816.48
7.4.30.0030.01316.48
7.4.00.0080.00814.89
7.3.330.0030.00313.23
7.3.320.0000.00613.06
7.3.310.0000.00716.10
7.3.300.0070.00016.27
7.3.290.0090.00716.28
7.3.280.0100.00716.24
7.3.270.0030.01317.40
7.3.260.0130.00916.28
7.3.250.0080.00916.44
7.3.240.0150.00316.25
7.3.230.0030.01716.54
7.3.210.0100.01016.47
7.3.200.0090.01319.39
7.3.190.0090.00716.35
7.3.180.0070.01016.35
7.3.170.0100.00616.27
7.3.160.0150.00916.27
7.3.120.0090.00814.78
7.3.110.0070.01014.77
7.3.100.0070.00614.78
7.3.90.0070.00714.78
7.3.80.0080.00514.75
7.3.70.0070.00514.73
7.3.60.0090.00814.63
7.3.50.0050.00814.70
7.3.40.0040.00914.76
7.3.30.0090.00614.57
7.3.20.0120.00916.61
7.3.10.0040.01016.46
7.3.00.0030.01016.57
7.2.330.0130.00316.48
7.2.320.0140.00916.41
7.2.310.0130.01916.72
7.2.300.0060.00916.54
7.2.290.0080.01416.41
7.2.250.0060.01114.89
7.2.240.0060.01314.89
7.2.230.0050.01114.97
7.2.220.0070.00814.98
7.2.210.0080.00914.91
7.2.200.0040.00614.93
7.2.190.0060.00914.80
7.2.180.0060.00814.84
7.2.170.0050.00714.86
7.2.160.0080.00315.03
7.2.150.0060.00916.58
7.2.140.0070.00316.72
7.2.130.0050.00916.72
7.2.120.0060.00816.80
7.2.110.0020.01116.64
7.2.100.0000.01116.80
7.2.90.0050.01216.61
7.2.80.0060.00916.86
7.2.70.0010.00816.75
7.2.60.0070.00716.66
7.2.50.0030.01216.81
7.2.40.0100.00516.79
7.2.30.0080.01016.79
7.2.20.0070.00716.63
7.2.10.0080.00816.54
7.2.00.0090.00517.68
7.1.330.0080.00715.55
7.1.320.0040.01015.69
7.1.310.0040.01115.72
7.1.300.0050.00915.66
7.1.290.0040.00915.59
7.1.280.0020.01115.51
7.1.270.0060.00815.63
7.1.260.0030.01115.63
7.1.250.0050.00815.53
7.1.240.0030.01015.79
7.1.230.0030.00715.68
7.1.220.0000.00815.51
7.1.210.0040.01115.38
7.1.200.0070.00715.69
7.1.190.0070.00715.78
7.1.180.0000.01515.82
7.1.170.0000.00915.61
7.1.160.0000.01515.82
7.1.150.0070.00715.59
7.1.140.0100.00315.66
7.1.130.0080.00315.67
7.1.120.0040.01115.63
7.1.110.0100.00315.82
7.1.100.0040.01116.80
7.1.90.0060.00615.63
7.1.80.0030.01015.73
7.1.70.0020.00916.18
7.1.60.0050.01217.46
7.1.50.0040.01316.10
7.1.40.0080.00315.60
7.1.30.0060.00615.30
7.1.20.0030.00915.53
7.1.10.0040.00415.39
7.1.00.0060.03818.90
7.0.330.0080.00415.23
7.0.320.0060.00615.11
7.0.310.0030.00615.42
7.0.300.0030.00915.29
7.0.290.0000.01515.38
7.0.280.0030.00615.53
7.0.270.0060.00615.36
7.0.260.0030.00915.24
7.0.250.0040.01115.19
7.0.240.0060.00915.48
7.0.230.0030.00915.00
7.0.220.0040.00415.45
7.0.210.0070.00415.27
7.0.200.0080.00416.04
7.0.190.0060.00315.37
7.0.180.0030.00815.11
7.0.170.0070.00415.41
7.0.160.0030.01015.32
7.0.150.0040.00915.31
7.0.140.0040.03618.63
7.0.130.0030.00715.14
7.0.120.0060.00315.41
7.0.110.0080.00415.43
7.0.100.0040.00415.00
7.0.90.0070.00015.41
7.0.80.0030.00915.26
7.0.70.0030.01015.11
7.0.60.0050.02417.77
7.0.50.0050.03216.51
7.0.40.0130.03316.59
7.0.30.0180.04316.63
7.0.20.0160.04616.64
7.0.10.0070.03016.74
7.0.00.0020.02816.69
5.6.380.0000.01514.30
5.6.370.0040.01114.30
5.6.360.0000.00914.27
5.6.350.0140.00314.23
5.6.340.0080.00614.09
5.6.330.0060.00814.54
5.6.320.0150.00014.46
5.6.310.0030.01014.09
5.6.300.0140.00013.98
5.6.290.0030.01014.42
5.6.280.0040.00813.99
5.6.270.0080.00614.48
5.6.260.0080.00314.33
5.6.250.0040.00714.56
5.6.240.0150.00014.38
5.6.230.0040.01214.27
5.6.220.0060.00314.32
5.6.210.0090.04517.55
5.6.200.0030.05016.13
5.6.190.0090.04617.39
5.6.180.0120.04717.17
5.6.170.0120.04317.34
5.6.160.0050.02217.38
5.6.150.0100.03716.23
5.6.140.0110.03316.29
5.6.130.0070.04216.13
5.6.120.0050.02317.83
5.6.110.0080.04617.58
5.6.100.0080.04317.61
5.6.90.0050.04817.81
5.6.80.0030.04517.30
5.6.70.2330.02317.36
5.6.60.0000.01213.88
5.6.50.0070.00414.33
5.6.40.0030.00914.05
5.6.30.0030.01014.10
5.6.20.0040.00414.41
5.6.10.0060.00614.09
5.6.00.0060.00614.01
5.5.380.0040.00811.18
5.5.370.0040.00811.18
5.5.360.0000.00711.18
5.5.350.0160.02115.77
5.5.340.0050.02214.62
5.5.330.0090.03315.85
5.5.320.0250.03715.72
5.5.310.0080.02415.79
5.5.300.0020.02714.57
5.5.290.0090.03614.58
5.5.280.0070.03016.04
5.5.270.0160.02115.97
5.5.260.0090.03616.00
5.5.250.0050.04215.89
5.5.240.0150.02115.77
5.5.230.0030.00911.18
5.5.220.0000.01011.18
5.5.210.0060.00011.18
5.5.200.0060.00311.18
5.5.190.0030.00711.18
5.5.180.0110.00011.18
5.5.170.0070.00011.18
5.5.160.0030.00611.18
5.5.150.0070.00411.18
5.5.140.0030.00311.18
5.5.130.0030.00611.18
5.5.120.0030.00711.18
5.5.110.0070.00411.18
5.5.100.0020.00511.27
5.5.90.0030.00611.18
5.5.80.0030.00711.18
5.5.70.0090.00311.18
5.5.60.0030.00911.18
5.5.50.0060.00611.18
5.5.40.0040.00411.18
5.5.30.0080.00411.18
5.5.20.0030.00311.18
5.5.10.0040.00411.18
5.5.00.0040.00411.18
5.4.450.0070.03415.24
5.4.440.0050.03515.33
5.4.430.0100.02715.18
5.4.420.0100.03015.17
5.4.410.0080.03115.26
5.4.400.0080.02615.24
5.4.390.0110.02615.22
5.4.380.0040.03415.17
5.4.370.0130.03115.22
5.4.360.0070.03315.02
5.4.350.0130.02615.23
5.4.340.0040.02311.61
5.4.330.0000.01111.18
5.4.320.0040.02111.85
5.4.310.0060.02111.85
5.4.300.0050.02411.85
5.4.290.0040.03011.85
5.4.280.0090.02011.80
5.4.270.0060.02211.80
5.4.260.0040.02511.80
5.4.250.0060.02011.80
5.4.240.0060.02311.80
5.4.230.0050.02311.79
5.4.220.0070.02011.79
5.4.210.0030.02111.79
5.4.200.0060.02011.79
5.4.190.0060.02011.79
5.4.180.0070.01911.79
5.4.170.0020.02411.80
5.4.160.0070.01911.80
5.4.150.0030.02111.79
5.4.140.0080.01911.64
5.4.130.0050.02211.63
5.4.120.0040.02111.61
5.4.110.0060.01811.61
5.4.100.0040.02811.61
5.4.90.0060.02311.61
5.4.80.0050.02011.61
5.4.70.0050.01911.61
5.4.60.0080.01811.61
5.4.50.0020.02211.61
5.4.40.0090.02311.60
5.4.30.0030.02211.60
5.4.20.0030.02111.60
5.4.10.0050.01911.60
5.4.00.0060.02011.34
5.3.290.0070.02811.99
5.3.280.0040.02211.94
5.3.270.0040.02311.95
5.3.260.0060.01911.95
5.3.250.0020.02311.95
5.3.240.0080.01911.95
5.3.230.0080.01811.94
5.3.220.0040.02211.93
5.3.210.0090.01811.93
5.3.200.0030.02311.93
5.3.190.0070.02411.93
5.3.180.0050.02211.93
5.3.170.0040.02111.92
5.3.160.0050.02211.92
5.3.150.0040.02311.92
5.3.140.0020.02211.92
5.3.130.0040.02111.92
5.3.120.0070.02911.92
5.3.110.0070.01911.92
5.3.100.0040.02211.66
5.3.90.0060.02311.65
5.3.80.0040.02211.65
5.3.70.0050.01911.65
5.3.60.0070.01811.64
5.3.50.0090.02111.61
5.3.40.0050.02511.62
5.3.30.0060.01911.59
5.3.20.0060.01911.48
5.3.10.0060.01911.47
5.3.00.0060.01911.46
5.2.170.0020.01810.21
5.2.160.0040.01710.21
5.2.150.0040.01810.21
5.2.140.0030.01710.21
5.2.130.0040.02110.19
5.2.120.0030.02410.19
5.2.110.0020.01910.20
5.2.100.0040.01710.19
5.2.90.0030.01910.19
5.2.80.0020.02310.19
5.2.70.0070.02010.19
5.2.60.0040.01910.17
5.2.50.0040.01910.15
5.2.40.0070.01810.14
5.2.30.0060.01410.13
5.2.20.0050.02610.12
5.2.10.0040.01710.08
5.2.00.0050.02110.01
5.1.60.0020.0179.65
5.1.50.0060.0159.65
5.1.40.0070.0149.64
5.1.30.0030.0189.82
5.1.20.0040.0149.83
5.1.10.0040.0229.69
5.1.00.0030.0149.69
5.0.50.0020.0148.93
5.0.40.0050.0088.87
5.0.30.0020.0178.77
5.0.20.0050.0138.75
5.0.10.0040.0108.75
5.0.00.0040.0278.74
4.4.90.0020.0197.98
4.4.80.0000.0107.96
4.4.70.0030.0107.96
4.4.60.0030.0097.96
4.4.50.0020.0167.97
4.4.40.0010.0197.94
4.4.30.0040.0097.97
4.4.20.0020.0108.01
4.4.10.0030.0088.01
4.4.00.0020.0147.97
4.3.110.0020.0167.92
4.3.100.0020.0137.92
4.3.90.0030.0097.90
4.3.80.0030.0137.89
4.3.70.0020.0097.90
4.3.60.0020.0097.90
4.3.50.0020.0087.90
4.3.40.0020.0137.86
4.3.30.0020.0107.27
4.3.20.0040.0077.26
4.3.10.0020.0137.23
4.3.00.0020.0138.98

preferences:
48.2 ms | 400 KiB | 5 Q