3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // include('database.php'); // require('fpdf.php'); class FPDF {} $process = new Process(); class PDF extends FPDF { function Header() { // Logo $this->Image('logo.png',10,6,30); // Arial bold 15 $this->SetFont('Arial','B',15); // Move to the right $this->Cell(80); // Title $this->Cell(30,10,'Title',1,0,'C'); // Line break $this->Ln(20); } function Footer() { // Position at 1.5 cm from bottom $this->SetY(-15); // Arial italic 8 $this->SetFont('Arial','I',8); // Page number $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C'); } } class Process { private $dbconn; private $pdf; private $resultarr = array(); private $identarr = array(); function __construct() { //$this->dbconn = new Database(); $this->pdf = new PDF(); $this->init(0); } private function init($i) { switch($i) { case 0: $query = "SELECT ident FROM vm_result WHERE date > NOW() - INTERVAL 7 DAY GROUP BY ident"; break; case 1: break; } $this->load_entries($query); } private function load_entries($query) { $result = $this->dbconn->query($query); while($row = $result->fetch_assoc()) { array_push($this->identarr, $row['ident']); } // loop per customer foreach($this->identarr as $ident) { $this->resultarr = array(); $query = "SELECT name, count, date FROM vm_result WHERE ident = '$ident' ORDER BY date ASC"; $result = $this->dbconn->query($query); while($row = $result->fetch_assoc()) { $str = $row['name'] . ':' . $row['count'] . ':' . $row['date']; array_push($this->resultarr, $str); } // summarize $this->summarize(); } } private function summarize() { foreach($this->resultarr as $entry) { $tmp = explode(":", $entry); $name = $tmp[0]; $count = $tmp[1]; $day = $tmp[2]; } } } ?>
based on aijSt
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to a member function query() on null in /in/IpK26:72 Stack trace: #0 /in/IpK26(66): Process->load_entries('SELECT ident FR...') #1 /in/IpK26(49): Process->init(0) #2 /in/IpK26(7): Process->__construct() #3 {main} thrown in /in/IpK26 on line 72
Process exited with code 255.
Output for hhvm-3.12.0
Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function query() on a non-object (null)' in /in/IpK26:72 Stack trace: #0 /in/IpK26(66): Process->load_entries() #1 /in/IpK26(49): Process->init() #2 /in/IpK26(7): Process->__construct() #3 {main}
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.7 - 5.6.28
Fatal error: Call to a member function query() on null in /in/IpK26 on line 72
Process exited with code 255.
Output for 5.0.0 - 5.5.35
Fatal error: Call to a member function query() on a non-object in /in/IpK26 on line 72
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/IpK26 on line 40
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/IpK26 on line 40
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/IpK26 on line 40
Process exited with code 255.