3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { public int $int; public string $string; public array $array; } class Foo { public Bar $bar; } class SimpleTest { // Static variables private int $int; private array $array; private string $string; // Object private Foo $foo; // This would be your setup(); function. public function __construct() { // Set the variables of your Class. $this->int = 1; $this->array = [0,1,2]; $this->string = "String"; // Create a Foo Object. $this->foo = new Foo(); // Create a Bar Object. $bar = new Bar(); // Set the variables of your Bar Object. $bar->string = $this->string; // Sets String $bar->int = $this->int; // Sets 1 $bar->array = $this->array; // Sets [0,1,2] // Set the variables of your Foo Object. $this->foo->bar = $bar; } public function test() { // Echo the current state of the variables from the Class. echo "Class: \n"; echo $this->int . "\n"; // 1 var_dump($this->array) . "\n"; // [0,1,2] echo $this->string . "\n"; // "String" // Echo the current state of the variables from the Object. echo "Object: \n"; echo $this->foo->bar->int . "\n"; // 1 var_dump($this->foo->bar->array) . "\n"; // [0,1,2] echo $this->foo->bar->string . "\n"; // "String" // Lets make some changes to the Class: $this->int = 2; $this->array = [2,1,0]; $this->string = "gnirtS"; // Echo the current state of the variables from the Class. echo "Second attempt for Class: \n"; echo $this->int . "\n"; // 2 var_dump($this->array) . "\n"; // [2,1,0] echo $this->string . "\n"; // "gnirtS" // Echo the current state of the variables from the Object. // The values WITHIN the Object have not changed. Eventhough we changed variables WITHIN the Class. // This proofs, that while on line 38-40 you THOUGHT you set a dynamic variables, you just set the values. echo "Second attempt for Object: \n"; echo $this->foo->bar->int . "\n"; // 1 var_dump($this->foo->bar->array) . "\n"; // [0,1,2] echo $this->foo->bar->string . "\n"; // "String" // Lets make some changes to the Object: $this->foo->bar->string = "Hello world"; // Sets Hello world $this->foo->bar->int = "999"; // Sets 999 $this->foo->bar->array = ["Hello", "world"]; // Sets ["Hello", "world"] // Echo the current state of the variables from the Class. // The values WITHIN the Class have not changed. Eventhough we changed variables WITHIN the Object. echo "Second attempt for Class: \n"; echo $this->int . "\n"; // 2 var_dump($this->array) . "\n"; // [2,1,0] echo $this->string . "\n"; // "gnirtS" // Echo the current state of the variables from the Object. echo "Second attempt for Object: \n"; echo $this->foo->bar->int . "\n"; // 999 var_dump($this->foo->bar->array) . "\n"; // ["Hello", "world"] echo $this->foo->bar->string . "\n"; // "Hello world" // Here is your difference: $bar = $this->foo->bar; $bar->string = "Elloh mister"; echo $this->foo->bar->string . "\n"; // "Elloh mister" echo $bar->string . "\n"; // "Elloh mister" // Here you dont have a difference: $int = $this->int; $int = 3; echo $this->int . "\n"; // 2 echo $int . "\n"; // 3 } } // Run your test. $simpleTest = new SimpleTest(); $simpleTest->test(); ?>

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.00.0150.00720.11
8.4.150.0030.00014.05
8.4.140.0110.01117.61
8.4.130.0090.00817.80
8.4.120.0100.01020.51
8.4.110.0120.00822.68
8.4.100.0150.00717.78
8.4.90.0110.01017.88
8.4.80.0060.00217.84
8.4.70.0050.00418.02
8.4.60.0090.00318.83
8.4.50.0120.00820.36
8.4.40.0060.00317.83
8.4.30.0060.01320.61
8.4.20.0070.01319.64
8.4.10.0070.00319.41
8.3.280.0140.00618.47
8.3.270.0150.00416.59
8.3.260.0130.00616.55
8.3.250.0060.01019.12
8.3.240.0090.01016.40
8.3.230.0100.00616.73
8.3.220.0100.00817.49
8.3.210.0100.01116.78
8.3.200.0050.00416.45
8.3.190.0130.00616.98
8.3.180.0110.00917.04
8.3.170.0060.01217.46
8.3.160.0140.00717.41
8.3.150.0070.01117.17
8.3.140.0060.00316.60
8.3.130.0040.00416.80
8.3.120.0060.00320.70
8.3.110.0110.00020.94
8.3.100.0030.00618.55
8.3.90.0090.00019.93
8.3.80.0060.00317.97
8.3.70.0120.00616.63
8.3.60.0040.01118.20
8.3.50.0140.00716.70
8.3.40.0030.01323.84
8.3.30.0110.00419.04
8.3.20.0040.00424.18
8.3.10.0080.00024.66
8.3.00.0080.00026.16
8.2.290.0080.00620.49
8.2.280.0160.00418.29
8.2.270.0030.01417.21
8.2.260.0100.01019.01
8.2.250.0070.01016.56
8.2.240.0030.00617.16
8.2.230.0060.00322.58
8.2.220.0030.00624.06
8.2.210.0060.00326.77
8.2.200.0060.00316.50
8.2.190.0120.00318.29
8.2.180.0110.00716.32
8.2.170.0120.00319.04
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0000.00721.00
8.2.110.0090.00020.94
8.2.100.0350.00018.44
8.2.90.0230.00818.44
8.2.80.0250.00518.44
8.2.70.0310.00018.44
8.2.60.0240.00818.44
8.2.50.0360.00418.44
8.2.40.0170.01318.44
8.2.30.0200.00718.44
8.2.20.0240.00418.44
8.2.10.0280.00018.44
8.2.00.0210.00518.44
8.1.330.0120.00716.88
8.1.320.0100.00916.06
8.1.310.0060.00618.68
8.1.300.0060.00319.91
8.1.290.0060.00618.88
8.1.280.0110.00725.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00022.18
8.1.230.0230.00318.44
8.1.220.0290.00018.44
8.1.210.0240.00318.44
8.1.200.0220.00718.44
8.1.190.0300.00018.44
8.1.180.0250.00418.44
8.1.170.0250.00318.44
8.1.160.0190.00818.44
8.1.150.0270.00318.44
8.1.140.0290.00018.44
8.1.130.0240.00318.44
8.1.120.0290.00318.44
8.1.110.0240.00418.44
8.1.100.0300.00018.44
8.1.90.0250.00318.44
8.1.80.0230.00318.44
8.1.70.0190.00718.44
8.1.60.0280.00318.44
8.1.50.0230.00319.27
8.1.40.0160.00718.44
8.1.30.0150.01218.44
8.1.20.0240.00318.44
8.1.10.0230.00318.44
8.1.00.0210.00418.44
8.0.300.0130.00418.44
8.0.290.0170.00318.44
8.0.280.0150.00718.44
8.0.270.0230.00018.44
8.0.260.0090.01318.44
8.0.250.0180.00418.44
8.0.240.0190.00518.44
8.0.230.0150.00718.44
8.0.220.0180.00618.44
8.0.210.0050.01618.44
8.0.200.0230.00018.44
8.0.190.0190.00418.44
8.0.180.0160.00518.44
8.0.170.0130.01018.44
8.0.160.0200.00318.44
8.0.150.0130.00718.44
8.0.140.0180.00518.44
8.0.130.0110.01118.44
8.0.120.0190.00518.44
8.0.110.0150.00818.44
8.0.100.0180.00518.44
8.0.90.0210.00218.44
8.0.80.0170.00618.44
8.0.70.0210.00118.44
8.0.60.0210.00318.44
8.0.50.0100.01018.44
8.0.30.0200.00818.44
8.0.20.0160.00418.44
8.0.10.0190.00418.44

preferences:
87.51 ms | 403 KiB | 5 Q