3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * * * array // aka is_array() * strict_array //alias of array * bool // if string representation is "1" or "0" or "on" or "off" or "true" or "false" * strict_bool //aka is_boolean() * float //check if string representation can be losslessly converted to an float.. * strict_float // aka is_float() * int // check if string representation can be losslessly converted to an int * strict_int // aka is_int() * string // check if variables can be converted to a string.. * strict_string //aka is_string() * null //aka is_null() * strict_null //alias of null * numeric //aka is_numeric() * strict_numeric // alias of numeric... maybe ill change this later * object //aka is_object() * strict_object //alias of object * callable //aka is_callable() * strict_callable //alias of callable * resource //aka is_resource() * strict_resource //alias of resource * integer //alias of int * strict_integer // alias of strict_int * double //alis of float * strict_double //alias of strict_float * real //alias of float * strict_real //alias of strict_float * scalar //aka is_scalar() * strict_scalar //alias of scalar * long //alias of int * strict_long //alias of strict_int * * * */ function hhb_mustbe1() { //throw new Exception("not implemented yet!! name reserved & function under development..."); //TODO: optimize this function, we have tons of useless variables and aliases that //should never have been declared at all... $argc = func_num_args(); if (!($argc>=2 && 0===($argc%2))) { throw new BadFunctionCallException('$argc=' . $argc . ' , argc must be >=2 and mod2===0, anything else is an obvious error!'); }; $validators = array(); $validators['array']=$valiate_array = function($invar) { return is_array($invar); }; $validators['strict_array']=$validate_strict_array = $validate_array; //alias. $validators['bool']=$validate_bool = function($invar) {$res = filter_var($invar, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); return $res !== null; }; $validators['strict_bool']=$validate_strict_bool = function($invar) { return is_bool($invar); }; $validators['float']=$validate_float = function($invar) {$res = filter_var($invar, FILTER_VALIDATE_FLOAT); return $res !== false; }; $validators['strict_float']=$validate_strict_float = function($invar) { return is_float($invar); }; $validators['int']=$validate_int = function($invar) {$res = filter_var($invar, FILTER_VALIDATE_INT); return $res !== false; }; $validators['strict_int']=$validate_strict_int = function($invar) { return is_infinite($invar); }; $validators['string']=$validate_string = function($invar) { //PS: there is very few things in PHP that cannot be threated like a string in php.. object lacking __toString is 1 try {$invar = (string)$invar; return true; } catch(Exception $ex) { return false; }; }; $validators['strict_string']=$validate_strict_string = function($invar) { return is_string($invar); }; $validators['null']=$validate_null = function($invar) { return is_null($invar); }; $validators['strict_null']=$validate_strict_null = $validate_null; //alias $validators['numeric']=$validate_numeric = function($invar) { return is_numeric($var); }; $validators['strict_numeric']=$validate_strict_numeric = $validate_numeric; //alias $validators['object']=$validate_object = function($invar) { return is_object($invar); }; $validators['strict_object']=$validate_strict_object = $validate_object; //alias $validators['callable']=$validate_callable = function($invar) { return is_callable($invar); }; $validators['strict_callable']=$validate_strict_callable = $validate_callable; //alias $validators['resource']=$validate_resource = function($invar) { return is_resource($invar); }; $validators['strict_resource']=$validate_strict_resource = $validate_resource; //alias $validators['integer']=$validate_integer = $validate_int; //alias $validators['strict_integer']=$validate_strict_integer = $validate_strict_int; //alias $validators['double']=$validate_double = $validate_float; //alias $validators['strict_double']=$validate_strict_double = $validate_strict_float; //alias $validators['real']=$validate_real = $validate_float; //alias $validators['strict_real']=$validate_strict_real = $validate_strict_float; //alias $validators['scalar']=$validate_scalar = function($invar) { return is_scalar($invar); }; $validators['strict_scalar']=$validate_strict_scalar = $validate_scalar; //alias $validators['long']=$validate_long = $validate_int; //alias $validators['strict_long']=$validate_strict_long = $validate_strict_int; //alias $operators=array('and'=>1,'or'=>1,'not'=>'unimplemented!'); $parse_validators=function($invar) use($validators,$operators){ if(!is_string($invar) && !is_array($invar)){ throw new BadFunctionCallException('you\'re using hhb_musbe1 wrong! every list of validators must be string or array!'); }; if(is_array($invar)){ throw new Exception("sorry, array of validators is not supported/implemented YET.."); // }; $rawlists=array($invar); $list=array(); $tmparr=array(); $next_must_be='validator';//ps: after first iteration, "must be" means "assuming there IS a next, next must be" foreach($rawlists as $rawlist){ $rawlist=preg_replace('/\s+/',' ',$rawlist); $rawlist=strtolower($rawlist); $tmparr=explode(" ",$rawlist); $previous_tmpval=null; foreach($tmparr as $tmpval){ if($next_must_be==='next_input'){//unreachable when used correctly! throw new BadFunctionCallException($previous_tmpval.' must be followed by a new value in the array! there can be nothing after it in the string! yet, i found '.$tmpval.' after it! syntax error..'); } else if($next_must_be==='validator'){ if(!array_key_exists($tmpval,$validators)){ throw BadFunctionCallException('"'.$rawvalidator.'" is not a recognized validator! recognized validator: "'.var_export(array_keys($validators),true).'""'); }; $list[]=array('validator',$tmpval); //NOTE: tricky strlen n shit? $next_must_be='operator'; $previous_tmpval=$tmpval; continue; } else if($next_must_be==='operator'){ if(!array_key_exists($tmpval,$operators)){ throw BadFunctionCallException('"'.$rawvalidator.'" is not a recognized operator! recognized operators: "'.var_export(array_keys($operators),true).'"'); } $list[]=array('operator',$tmpval); $next_must_be='validator'; $previous_tmpval=$tmpval; continue; }//else {/*ERROR! SHOULD BE UNREACHABLE!*/ throw new LogicException('error! unreachable code..reached; probably caused by invalid $next_must_be='.var_export($next_must_be,true).''); } } } }; }; function hhb_mustbe2(/*void*/) { throw new Exception("not implemented yet!! name reserved..."); class validator_class { public $invoke_counter = 0; function __destruct() { } }; return new validator_class(); };

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.0110.01118.43
8.3.50.0130.00821.21
8.3.40.0060.00918.49
8.3.30.0070.00720.21
8.3.20.0080.00020.39
8.3.10.0040.00420.80
8.3.00.0040.00423.48
8.2.180.0120.00916.38
8.2.170.0040.01122.96
8.2.160.0140.00020.64
8.2.150.0000.00824.18
8.2.140.0100.01024.66
8.2.130.0030.00526.16
8.2.120.0000.00820.99
8.2.110.0040.00720.70
8.2.100.0040.00817.78
8.2.90.0030.00518.92
8.2.80.0000.00719.51
8.2.70.0030.00617.38
8.2.60.0030.00517.93
8.2.50.0040.00418.07
8.2.40.0040.00418.03
8.2.30.0030.00521.33
8.2.20.0040.00417.60
8.2.10.0050.00317.55
8.2.00.0030.00517.75
8.1.280.0070.00725.92
8.1.270.0000.00823.99
8.1.260.0070.00026.35
8.1.250.0000.00728.09
8.1.240.0040.00422.45
8.1.230.0090.00321.03
8.1.220.0030.00518.77
8.1.210.0000.00818.95
8.1.200.0000.00917.23
8.1.190.0060.00317.53
8.1.180.0000.00818.10
8.1.170.0000.00818.57
8.1.160.0000.00818.89
8.1.150.0000.00718.66
8.1.140.0030.00617.40
8.1.130.0050.00517.70
8.1.120.0080.00017.41
8.1.110.0030.00617.38
8.1.100.0000.00717.43
8.1.90.0050.00317.30
8.1.80.0040.00417.30
8.1.70.0070.00017.37
8.1.60.0030.00617.51
8.1.50.0040.00417.48
8.1.40.0030.00617.41
8.1.30.0030.00517.65
8.1.20.0060.00317.52
8.1.10.0040.00417.51
8.1.00.0040.00417.40
8.0.300.0040.00420.02
8.0.290.0080.00017.18
8.0.280.0020.00518.33
8.0.270.0040.00417.09
8.0.260.0070.00016.82
8.0.250.0040.00416.86
8.0.240.0060.00317.00
8.0.230.0000.00816.81
8.0.220.0000.00716.86
8.0.210.0030.00316.73
8.0.200.0030.00516.94
8.0.190.0040.00416.91
8.0.180.0000.00716.86
8.0.170.0000.00816.81
8.0.160.0050.00216.81
8.0.150.0040.00416.90
8.0.140.0050.00316.85
8.0.130.0000.00613.31
8.0.120.0040.00416.82
8.0.110.0040.00416.90
8.0.100.0070.00016.84
8.0.90.0000.00816.72
8.0.80.0090.00616.90
8.0.70.0040.00416.82
8.0.60.0040.00416.74
8.0.50.0050.00316.74
8.0.30.0080.01117.14
8.0.20.0070.01217.40
8.0.10.0000.00716.79
8.0.00.0120.00516.60
7.4.330.0000.00516.71
7.4.320.0030.00316.49
7.4.300.0000.00616.48
7.4.290.0000.00716.48
7.4.280.0030.00716.55
7.4.270.0070.00016.54
7.4.260.0030.00313.25
7.4.250.0070.00016.54
7.4.240.0030.00316.56
7.4.230.0050.00316.64
7.4.220.0060.01216.41
7.4.210.0090.00716.50
7.4.200.0000.00716.45
7.4.190.0000.00716.63
7.4.160.0100.01016.55
7.4.150.0190.00617.40
7.4.140.0050.01417.86
7.4.130.0140.00716.37
7.4.120.0140.00616.40
7.4.110.0090.00916.35
7.4.100.0120.00616.47
7.4.90.0100.01416.38
7.4.80.0100.00719.39
7.4.70.0060.01016.42
7.4.60.0070.01016.59
7.4.50.0030.00316.54
7.4.40.0070.01022.77
7.4.30.0070.00816.34
7.4.00.0080.00714.92
7.3.330.0000.00513.03
7.3.320.0000.00513.08
7.3.310.0000.00716.25
7.3.300.0030.00316.23
7.3.290.0070.00816.29
7.3.280.0120.01116.26
7.3.270.0140.00417.40
7.3.260.0140.01018.24
7.3.250.0120.01016.51
7.3.240.0110.00616.59
7.3.230.0090.00916.39
7.3.210.0160.00616.35
7.3.200.0100.01319.39
7.3.190.0120.00916.42
7.3.180.0060.01116.18
7.3.170.0110.01216.56
7.3.160.0070.01016.52
7.3.120.0080.00814.63
7.3.110.0070.01014.54
7.3.100.0090.00314.90
7.3.90.0000.01414.81
7.3.80.0030.01214.66
7.3.70.0030.01414.78
7.3.60.0060.00914.47
7.3.50.0100.00014.46
7.3.40.0030.00614.75
7.3.30.0070.00314.66
7.3.20.0080.00616.45
7.3.10.0000.01516.55
7.3.00.0080.00416.36
7.2.330.0030.01616.72
7.2.320.0110.00716.32
7.2.310.0100.00916.41
7.2.300.0100.00616.34
7.2.290.0060.01216.51
7.2.250.0030.01515.05
7.2.240.0120.00914.84
7.2.230.0060.00915.12
7.2.220.0000.01414.80
7.2.210.0030.01014.68
7.2.200.0000.00915.04
7.2.190.0030.01314.82
7.2.180.0040.00814.71
7.2.170.0070.00714.79
7.2.00.0040.00819.27
7.1.330.0060.01015.67
7.1.320.0090.00015.73
7.1.310.0120.00615.51
7.1.300.0070.00715.53
7.1.290.0090.00615.49
7.1.280.0070.00315.34
7.1.270.0080.00815.31
7.1.260.0040.00715.47
7.1.100.0070.00317.72
7.1.70.0030.00616.85
7.1.60.0000.02219.17
7.1.50.0090.01216.62
7.1.00.0000.07022.48
7.0.200.0000.01016.37
7.0.140.0070.07022.19
7.0.100.0070.07320.06
7.0.90.0130.07020.12
7.0.80.0130.07320.05
7.0.70.0030.08320.09
7.0.60.0170.07320.04
7.0.50.0170.06720.39
7.0.40.0000.09020.11
7.0.30.0030.09019.96
7.0.20.0130.08020.09
7.0.10.0070.07720.18
7.0.00.0100.06020.03
5.6.280.0100.06721.08
5.6.250.0130.05320.60
5.6.240.0030.08720.73
5.6.230.0000.08720.72
5.6.220.0100.05020.71
5.6.210.0070.05720.75
5.6.200.0000.08721.18
5.6.190.0100.08321.03
5.6.180.0000.08321.18
5.6.170.0130.08721.11
5.6.160.0100.07721.18
5.6.150.0100.08021.09
5.6.140.0030.05321.15
5.6.130.0100.07721.13
5.6.120.0130.07721.07
5.6.110.0070.04721.06
5.6.100.0000.08721.14
5.6.90.0100.07721.09
5.6.80.0130.05720.40
5.6.70.0130.07720.39
5.6.60.0130.07320.36
5.6.50.0100.04720.54
5.6.40.0130.06320.55
5.6.30.0030.08320.53
5.6.20.0000.06020.37
5.6.10.0100.08020.49
5.6.00.0130.07020.54
5.5.380.0130.07320.42
5.5.370.0070.05020.42
5.5.360.0070.06720.43
5.5.350.0130.07320.44
5.5.340.0170.07020.84
5.5.330.0030.08720.99
5.5.320.0070.08320.80
5.5.310.0130.08020.93
5.5.300.0130.07720.89
5.5.290.0030.07320.91
5.5.280.0070.08020.79
5.5.270.0100.07320.70
5.5.260.0130.07320.81
5.5.250.0130.06320.77
5.5.240.0100.07720.37
5.5.230.0070.08020.23
5.5.220.0100.07020.21
5.5.210.0030.08020.30
5.5.200.0230.06020.32
5.5.190.0030.08320.25
5.5.180.0170.07720.30
5.5.160.0100.07720.22
5.5.150.0100.07720.29
5.5.140.0100.06320.24
5.5.130.0030.08720.24
5.5.120.0100.07020.29
5.5.110.0030.08320.32
5.5.100.0030.05320.14
5.5.90.0030.08020.11
5.5.80.0070.07720.21
5.5.70.0130.07320.02
5.5.60.0030.08320.08
5.5.50.0100.06320.15
5.5.40.0030.08020.08
5.5.30.0030.08020.17
5.5.20.0070.07320.09
5.5.10.0070.08020.07
5.5.00.0070.07720.02
5.4.450.0130.07719.48
5.4.440.0070.07719.38
5.4.430.0070.08019.56
5.4.420.0000.09019.58
5.4.410.0100.06019.23
5.4.400.0130.06718.89
5.4.390.0030.07319.19
5.4.380.0070.06719.14
5.4.370.0130.05718.97
5.4.360.0100.04319.19
5.4.350.0070.07319.04
5.4.340.0030.08019.05
5.4.320.0070.07719.10
5.4.310.0100.07018.88
5.4.300.0130.07019.05
5.4.290.0130.07018.91
5.4.280.0000.05718.84
5.4.270.0070.07319.16
5.4.260.0030.08019.05
5.4.250.0130.07019.16
5.4.240.0070.08019.06
5.4.230.0100.07019.18
5.4.220.0070.04719.23
5.4.210.0200.06719.13
5.4.200.0130.07019.03
5.4.190.0170.07019.13
5.4.180.0130.07019.04
5.4.170.0100.04318.84
5.4.160.0070.07719.08
5.4.150.0130.06018.93
5.4.140.0030.04016.52
5.4.130.0070.06016.39
5.4.120.0070.06716.24
5.4.110.0070.06716.50
5.4.100.0030.05716.38
5.4.90.0100.06316.55
5.4.80.0070.07716.57
5.4.70.0000.04016.57
5.4.60.0100.07316.43
5.4.50.0000.08016.50
5.4.40.0000.04016.54
5.4.30.0100.05016.46
5.4.20.0070.06716.46
5.4.10.0030.07716.42
5.4.00.0130.06315.91
5.3.290.0030.08014.88
5.3.280.0070.07714.68
5.3.270.0100.07314.71
5.3.260.0030.05714.75
5.3.250.0070.07314.75
5.3.240.0130.06014.64
5.3.230.0030.07314.61
5.3.220.0130.06014.73
5.3.210.0100.04714.57
5.3.200.0130.07014.74
5.3.190.0130.07014.60
5.3.180.0130.07314.76
5.3.170.0070.07014.71
5.3.160.0070.06014.65
5.3.150.0070.07314.71
5.3.140.0070.07014.56
5.3.130.0070.07314.61
5.3.120.0070.07314.64
5.3.110.0070.07714.64
5.3.100.0070.07714.16
5.3.90.0030.07314.16
5.3.80.0100.07314.16
5.3.70.0070.07014.16
5.3.60.0130.07014.16
5.3.50.0100.03714.16
5.3.40.0030.07714.16
5.3.30.0070.04314.16
5.3.20.0130.07014.16
5.3.10.0030.04314.16
5.3.00.0000.08014.16

preferences:
47.99 ms | 401 KiB | 5 Q