3v4l.org

run code in 300+ PHP versions simultaneously
<?php class segitiga { protected $alas; protected $tinggi; public function setalas ($a) { $pr=$this->$alas; $pr=10; return $pr; } public function settinggi ($a) { $tgg=$this->$tinggi; $tgg=15; return $tgg; } } class hitmir extends segitiga { protected $miring; private function hit($a) { $mir=($pr*$pr+$tgg*$tgg); } } $ob= new segitiga(); $ob2= new hitmir(); echo PHP_EOL; $ob2->this->hit();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Warning: Undefined property: hitmir::$this in /in/pg15B on line 31 Fatal error: Uncaught Error: Call to a member function hit() on null in /in/pg15B:31 Stack trace: #0 {main} thrown in /in/pg15B on line 31
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined property: hitmir::$this in /in/pg15B on line 31 Fatal error: Uncaught Error: Call to a member function hit() on null in /in/pg15B:31 Stack trace: #0 {main} thrown in /in/pg15B on line 31
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught Error: Call to a member function hit() on null in /in/pg15B:31 Stack trace: #0 {main} thrown in /in/pg15B on line 31
Process exited with code 255.
Output for 5.6.38
Notice: Undefined property: hitmir::$this in /in/pg15B on line 31 Fatal error: Call to a member function hit() on null in /in/pg15B on line 31
Process exited with code 255.

preferences:
157.57 ms | 401 KiB | 174 Q