3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Segitiga { protected $alas; protected $tinggi; public function __construct($alas,$tinggi){ $this->alas = $alas; $this->tinggi = $tinggi; } public function hitungLuas(){ return (0.5 * $this->alas * $this->tinggi); } } class SisiMiring { protected $miring; } function hitungSisiMiring(){ return ($this->miring = $segitiga * 2); } $segitiga = new Segitiga(4,5); echo 'Luas Segitiga = '.$segitiga->hitungLuas() . "\n"; $sisimiring = new SisiMiring(); echo 'Sisi Miring Segitiga ='.$sisimiriing->hitungSisiMiring()."\n"; ?>
based on UXMgo
Output for 7.0.28 - 7.3.0rc3
Luas Segitiga = 10 Notice: Undefined variable: sisimiriing in /in/seAIA on line 29 Fatal error: Uncaught Error: Call to a member function hitungSisiMiring() on null in /in/seAIA:29 Stack trace: #0 {main} thrown in /in/seAIA on line 29
Process exited with code 255.
Output for 5.6.38
Luas Segitiga = 10 Notice: Undefined variable: sisimiriing in /in/seAIA on line 29 Fatal error: Call to a member function hitungSisiMiring() on null in /in/seAIA on line 29
Process exited with code 255.