3v4l.org

run code in 300+ PHP versions simultaneously
<?php Class Vehicle{ /* Delcaration of private variables */ private $_name = "Default Vehicle"; private $_model; private $_type; private $_identification; /* Declaration of private arrays */ private $_mode = array(); private $feature = array(); /* Magic code entry function, think of it as a main() in C/C++ */ public function __construct( $name, $model, $type ){ $this->create_vehicle( $name, $model, $type ); } /* __getter function */ public function __get( $variable ){ if( !empty($this->$variable) ){ $get_variable = $this->$variable; } return $get_variable; } /* __setter function */ public function __set( $variable, $target ){ $this->$variable = $target; } /* Private function */ private function create_vehicle( $name, $model, $type ){ $this->__set( "_name", $name ); $this->__set( "_model", $model); $this->__set( "_type", $type ); } } //end of the class. ?> <?php /* Using the Vehicle class to create a vehicle by passing three parameters 'vehicle name', 'vehicle model', 'vehicle type' to the class. */ $toyota = new Vehicle("Toyotal 101", "TY101", "Sedan"); /* Get the name and store it in a variable for later use */ $vehicle_name = $toyota->__get('_name'); /* Set the vehicle mode or status */ $vehicle_mode = array( 'gas' => 50, 'ignition' => 'OFF', 'tire' => "OK", 'year' => 2020, 'mfg' => 'Toyoda', 'condition' => 'New' ); /* Create vehicle features */ $vehicle_feature = array( "Tire" => 4, "Horse Power" => "V6", "blah blah" => "foo", "Airbag" => 2, "Transmission" => "Automatic" //.... ); /* Create vehicle identification */ $vehicle_identification = array( "VIN" => "0001234567ABCD89", "NAME" => $vehicle_name, "FEATURE" => $vehicle_feature, "MODEL" => $vehicle_mode, "YEAR" => 2020, "MFG" => "Totota" ); /* Set vehicle identification */ $toyota->__set("_identification", $vehicle_identification ); /* Set vehicle features */ $toyota->__set("_feature", $vehicle_feature ); /* Set vehicle mode */ $toyota->__set("_mode", $vehicle_mode); /* Retrieve information and store them in variable using __get (getter) */ $vehicle_name = $toyota->__get('_name'); $vehicle_mode = $toyota->__get('_mode'); $vehicle_id = $toyota->__get('_identification'); $vehicle_features = $toyota->__get('_feature'); $vehicle_type = $toyota->__get('_type'); $vehicle_model = $toyota->__get('_model'); /* Printing information using store values in the variables. */ echo "Printing Vehicle Information\n"; echo "*****************************\n"; echo "Vehicle name is $vehicle_name \n"; echo "Vehicle Model is $vehicle_model \n"; echo "Vehich type is $vehicle_type \n"; printf("\n\n"); echo "Printing Vehicle Mode\n"; echo "***********************\n"; print_r( $vehicle_mode ); printf("\n\n"); echo "Printing Vehicle Features\n"; echo "**************************\n"; print_r( $vehicle_features ); printf("\n\n"); echo "Printing Vehicle Identification\n"; echo "******************************\n"; print_r( $vehicle_id ); printf("\n\n"); ?>

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.5.10.0150.00916.72
8.5.00.0120.01020.14
8.4.150.0030.00014.05
8.4.140.0080.01417.93
8.4.130.0100.01118.81
8.4.120.0060.00324.08
8.4.110.0080.00918.73
8.4.100.0110.00918.71
8.4.90.0110.01117.98
8.4.80.0080.00718.05
8.4.70.0120.00917.96
8.4.60.0110.00918.71
8.4.50.0110.00917.93
8.4.40.0040.00419.43
8.4.30.0150.00618.70
8.4.20.0060.01320.67
8.4.10.0000.00917.86
8.3.280.0110.01118.35
8.3.270.0120.00816.78
8.3.260.0140.00516.91
8.3.250.0060.00418.97
8.3.240.0090.01017.25
8.3.230.0050.00416.70
8.3.220.0040.00418.82
8.3.210.0060.00218.47
8.3.200.0070.01216.80
8.3.190.0060.00216.76
8.3.180.0050.00318.61
8.3.170.0090.00917.25
8.3.160.0070.01120.75
8.3.150.0090.00918.32
8.3.140.0000.01116.90
8.3.130.0040.00418.49
8.3.120.0140.00719.35
8.3.110.0060.00320.94
8.3.100.0060.00316.88
8.3.90.0070.00726.77
8.3.80.0060.00317.97
8.3.70.0110.00716.75
8.3.60.0090.00616.74
8.3.50.0110.00318.21
8.3.40.0140.00418.65
8.3.30.0000.01518.78
8.3.20.0040.00420.65
8.3.10.0050.00320.30
8.3.00.0030.00722.43
8.2.290.0070.00322.38
8.2.280.0120.00918.23
8.2.270.0070.01117.23
8.2.260.0060.01218.95
8.2.250.0090.00018.65
8.2.240.0000.00817.29
8.2.230.0060.00322.58
8.2.220.0000.00824.06
8.2.210.0190.00026.77
8.2.200.0000.01016.38
8.2.190.0120.00316.88
8.2.180.0120.00618.54
8.2.170.0090.00622.96
8.2.160.0070.00722.12
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0060.00319.36
8.2.110.0090.00220.77
8.2.100.0040.00720.23
8.2.90.0080.00318.53
8.2.80.0070.00318.78
8.2.70.0090.00318.12
8.2.60.0110.00118.20
8.2.50.0060.00618.17
8.2.40.0050.00619.93
8.2.30.0070.00419.17
8.2.20.0100.00118.48
8.2.10.0070.00319.40
8.2.00.0110.00019.21
8.1.330.0100.01221.79
8.1.320.0100.00916.25
8.1.310.0150.00418.34
8.1.300.0040.00420.36
8.1.290.0060.00318.88
8.1.280.0070.01425.92
8.1.270.0040.00424.66
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0030.00819.71
8.1.230.0050.00919.80
8.1.220.0110.00118.11
8.1.210.0090.00219.39
8.1.200.0090.00317.93
8.1.190.0050.00717.91
8.1.180.0080.00418.24
8.1.170.0050.00618.60
8.1.160.0030.00719.04
8.1.150.0060.00319.72
8.1.140.0080.00219.44
8.1.130.0070.00319.34
8.1.120.0070.00418.06
8.1.110.0080.00317.93
8.1.100.0090.00318.03
8.1.90.0060.00418.00
8.1.80.0030.00818.08
8.1.70.0040.00618.12
8.1.60.0090.00418.17
8.1.50.0090.00517.99
8.1.40.0090.00318.17
8.1.30.0050.00818.22
8.1.20.0070.00618.09
8.1.10.0070.00418.24
8.1.00.0070.00418.06
8.0.300.0090.00218.92
8.0.290.0080.00417.19
8.0.280.0050.00618.08
8.0.270.0100.00217.41
8.0.260.0080.00319.03
8.0.250.0090.00217.45
8.0.240.0070.00417.46
8.0.230.0080.00217.67
8.0.220.0100.00217.30
8.0.210.0070.00417.51
8.0.200.0080.00417.46
8.0.190.0060.00517.47
8.0.180.0080.00317.47
8.0.170.0060.00617.37
8.0.160.0050.00717.43
8.0.150.0080.00317.39
8.0.140.0080.00417.28
8.0.130.0070.00215.76
8.0.120.0070.00417.42
8.0.110.0090.00217.50
8.0.100.0060.00417.08
8.0.90.0100.00717.25
8.0.80.0090.00817.08
8.0.70.0080.00817.14
8.0.60.0070.00717.13
8.0.50.0110.00917.09
8.0.30.0080.01117.12
8.0.20.0140.00517.23
8.0.10.0090.00717.25
8.0.00.0080.00918.25
7.4.330.0090.00415.92
7.4.320.0090.00217.15
7.4.300.0030.00817.94
7.4.290.0090.00017.87
7.4.280.0070.00417.15
7.4.270.0050.00317.84
7.4.260.0050.00216.37
7.4.250.0060.00217.91
7.4.240.0010.00617.51
7.4.230.0070.00317.01
7.4.220.0030.00417.17
7.4.210.0070.00717.06
7.4.200.0090.00417.33
7.4.190.0040.01116.93
7.4.180.0070.00717.35
7.4.160.0050.00817.36
7.4.150.0030.00817.27
7.4.140.0030.00817.11
7.4.130.0070.00716.78
7.4.120.0090.00516.64
7.4.110.0120.00716.68
7.4.100.0090.00716.76
7.4.90.0110.00616.69
7.4.80.0130.00617.27
7.4.70.0070.01016.70
7.4.60.0130.00616.70
7.4.50.0120.00716.62
7.4.40.0110.01016.63
7.4.30.0090.00916.66
7.4.20.0080.00716.67
7.4.10.0090.00816.72
7.4.00.0060.01016.75
7.3.330.0080.00217.02
7.3.320.0070.00415.40
7.3.310.0080.00316.93
7.3.300.0050.00516.72
7.3.290.0080.00616.58
7.3.280.0100.00316.66
7.3.270.0100.00516.68
7.3.260.0120.00616.60
7.3.250.0070.00716.67
7.3.240.0090.00716.51
7.3.230.0100.00616.59
7.3.220.0080.00516.56
7.3.210.0110.00616.57
7.3.200.0110.00716.56
7.3.190.0110.00616.58
7.3.180.0090.00716.58
7.3.170.0080.00716.51
7.3.160.0060.00916.57
7.3.150.0100.00516.57
7.3.140.0130.00816.57
7.3.130.0130.00716.62
7.3.120.0090.00916.28
7.3.110.0120.00716.20
7.3.100.0100.00916.02
7.3.90.0090.00816.23
7.3.80.0090.00616.11
7.3.70.0100.00416.13
7.3.60.0090.00616.16
7.3.50.0110.00616.09
7.3.40.0090.00616.12
7.3.30.0080.00916.13
7.3.20.0090.00816.92
7.3.10.0110.00616.96
7.3.00.0060.00916.89
7.2.340.0120.00817.02
7.2.330.0160.00616.57
7.2.320.0150.00716.52
7.2.310.0120.00816.62
7.2.300.0140.00616.60
7.2.290.0150.00716.66
7.2.280.0130.00716.50
7.2.270.0130.00816.57
7.2.260.0170.00616.55
7.2.250.0140.00816.55
7.2.240.0170.00516.24
7.2.230.0110.00716.17
7.2.220.0130.00616.18
7.2.210.0160.00716.10
7.2.200.0130.00516.30
7.2.190.0090.00916.28
7.2.180.0120.00616.26
7.2.170.0100.00716.24
7.2.160.0130.00416.25
7.2.150.0120.00716.78
7.2.140.0120.00916.79
7.2.130.0120.00916.96
7.2.120.0090.01016.77
7.2.110.0120.00616.88
7.2.100.0140.00616.82
7.2.90.0190.00716.79
7.2.80.0130.00816.89
7.2.70.0110.00916.82
7.2.60.0130.01016.82
7.2.50.0110.00716.82
7.2.40.0110.00916.93
7.2.30.0100.00916.85
7.2.20.0110.00716.92
7.2.10.0120.00817.06
7.2.00.0090.00716.87
7.1.330.0080.00916.09
7.1.320.0240.00715.79
7.1.310.0170.00815.91
7.1.300.0120.00715.84
7.1.290.0130.00715.75
7.1.280.0140.00615.76
7.1.270.0120.00815.72
7.1.260.0100.00815.77
7.1.250.0130.00515.71
7.1.240.0120.00616.10
7.1.230.0110.00616.14
7.1.220.0130.00416.12
7.1.210.0140.00616.11
7.1.200.0080.01216.10
7.1.190.0110.00716.06
7.1.180.0120.00616.07
7.1.170.0110.00616.30
7.1.160.0100.00816.13
7.1.150.0140.00516.12
7.1.140.0120.00616.04
7.1.130.0140.00516.06
7.1.120.0150.00816.04
7.1.110.0200.00716.17
7.1.100.0300.00616.15
7.1.90.0120.00616.14
7.1.80.0130.00516.08
7.1.70.0120.00715.97
7.1.60.0110.00716.12
7.1.50.0140.00516.14
7.1.40.0140.00716.19
7.1.30.0150.00616.13
7.1.20.0210.00716.13
7.1.10.0110.00916.10
7.1.00.0170.00516.05

preferences:
47.2 ms | 403 KiB | 5 Q