3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Car { public $atr1; public $atr2; public $atr3; function _construct($atr1,$atr2,$atr3) { $this->atr1=$atr1; $this->atr2=$atr2; $this->atr3=$atr3; } public function getatr1() { return $this->$atr1; } public function getatr2() { return $this->atr2; } public function getatr3() { return $this->atr3; } } function napln() { $obj1 = new Car("renault","modra",'nieco'); $obj2 = new Car('skoda','zelena','neviem'); $obj3 = new Car('opel','cervena','cojaviem'); echo ($obj1->getatr1()); $pole = array($obj1, $obj2, $obj3); return $pole; } function tabulka() { $table_str='<table>'; $table=napln(); foreach($table as $tab) { $table_str.= '<tr>'; $table_str.='<td>'.$tab -> getatr1().'</td><td>'.$tab -> getatr2().'</td><td>'.$tab -> getatr3().'</td>'; $table_str.='</tr>'; } $table_str.='</table>'; return $table_str; } ?> <html> <head> <title>Page Title</title> </head> <body> <?php echo tabulka(); ?> </body> </html>
based on MOTdl
Output for 7.1.0 - 7.2.0
<html> <head> <title>Page Title</title> </head> <body> Notice: Undefined variable: atr1 in /in/70YKp on line 17 Notice: Undefined property: Car::$ in /in/70YKp on line 17 Notice: Undefined variable: atr1 in /in/70YKp on line 17 Notice: Undefined property: Car::$ in /in/70YKp on line 17 Notice: Undefined variable: atr1 in /in/70YKp on line 17 Notice: Undefined property: Car::$ in /in/70YKp on line 17 Notice: Undefined variable: atr1 in /in/70YKp on line 17 Notice: Undefined property: Car::$ in /in/70YKp on line 17 <table><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></table> </body> </html>
Output for 7.0.0 - 7.0.20
<html> <head> <title>Page Title</title> </head> <body> Notice: Undefined variable: atr1 in /in/70YKp on line 17 Fatal error: Uncaught Error: Cannot access empty property in /in/70YKp:17 Stack trace: #0 /in/70YKp(38): Car->getatr1() #1 /in/70YKp(45): napln() #2 /in/70YKp(63): tabulka() #3 {main} thrown in /in/70YKp on line 17
Process exited with code 255.
Output for 5.3.19 - 5.6.28
<html> <head> <title>Page Title</title> </head> <body> Notice: Undefined variable: atr1 in /in/70YKp on line 17 Fatal error: Cannot access empty property in /in/70YKp on line 17
Process exited with code 255.