3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Kubus { public function set_sisi($s); public function luas_kubus(); public function volume_kubus(); } interface Balok { public function luas_balok($p, $l); public function volume_balok($t); } class Hitung implements Kubus, Balok{ public $p,$l,$sisi; public function set_sisi($s) { $this->sisi = $s; return $this; } public function luas_kubus() { echo "Luas Kubus = " . $this->sisi * 2 . PHP_EOL; return $this; } public function volume_kubus() { echo "Volume Kubus = " . $this->sisi * 3 . PHP_EOL; return $this; } public function luas_balok($p, $l) { $this->p = $p; $this->l = $l; echo "Luas Balok = " . $p * $l . PHP_EOL; return $this; } public function volume_balok($t) { echo "Volume Balok = " . $this->p * $this->l * $t . PHP_EOL; } } $hitung = new Hitung; echo $hitung->set_sisi(4)->luas_kubus()->volume_kubus()->luas_balok(8,4)->volume_balok();
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Luas Kubus = 8 Volume Kubus = 12 Luas Balok = 32 Fatal error: Uncaught ArgumentCountError: Too few arguments to function Hitung::volume_balok(), 0 passed in /in/A3PYF on line 41 and exactly 1 expected in /in/A3PYF:35 Stack trace: #0 /in/A3PYF(41): Hitung->volume_balok() #1 {main} thrown in /in/A3PYF on line 35
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Luas Kubus = 8 Volume Kubus = 12 Luas Balok = 32 Fatal error: Uncaught ArgumentCountError: Too few arguments to function Hitung::volume_balok(), 0 passed in /in/A3PYF on line 41 and exactly 1 expected in /in/A3PYF:35 Stack trace: #0 /in/A3PYF(41): Hitung->volume_balok() #1 {main} thrown in /in/A3PYF on line 35
Process exited with code 255.

preferences:
168.78 ms | 401 KiB | 183 Q