3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // This library is to rewrite MSYQL queries into formatted text class query2text { private $key_arr; public function addline ($query,$keyword) { $fixed = str_ireplace(" ".$keyword,"<br>&nbsp;".$keyword,$query); return $fixed; } public function convert($query) { $key_arr = array("FROM","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","WHERE","AND","OR","ORDER","GROUP"); foreach($key_arr AS $key) { $query = $this->addline($query,$key); } $query .= "<br><br>\n"; return $query; } } $query = "SELECT patients.patient_id,patients.last_name,patients.first_name,appts.*,appt_types.type,appt_types.color,appt_types.bgcolor" . ",DATE_FORMAT(appts.start,'%m/%d/%Y') AS date" . ",DATE_FORMAT(appts.start,'%h:%i %p') AS time" . ",TIMEDIFF(appts.end,appts.start) AS duration" . " FROM patients,appts,appt_types" . " WHERE appts.cancelled IS NULL" . " AND YEAR(appts.start)='" . $year . "'" . " AND MONTH(appts.start)='" . $month . "'" . " AND DAY(appts.start)='" . $day . "'" . " AND patients.patient_id = appts.patient_id" . " AND appts.type = appt_types.appt_type_id"; $q2t = new query2text(); echo "<hr>" . $q2t->convert($query) . "<hr>\n";
Output for 5.0.4 - 5.6.28, hhvm-3.10.0, 7.0.0 - 7.1.0
Notice: Undefined variable: year in /in/3TqDc on line 34 Notice: Undefined variable: month in /in/3TqDc on line 35 Notice: Undefined variable: day in /in/3TqDc on line 36 <hr>SELECT patients.patient_id,patients.last_name,patients.first_name,appts.*,appt_types.type,appt_types.color,appt_types.bgcolor,DATE_FORMAT(appts.start,'%m/%d/%Y') AS date,DATE_FORMAT(appts.start,'%h:%i %p') AS time,TIMEDIFF(appts.end,appts.start) AS duration<br>&nbsp;FROM patients,appts,appt_types<br>&nbsp;WHERE appts.cancelled IS NULL<br>&nbsp;AND YEAR(appts.start)=''<br>&nbsp;AND MONTH(appts.start)=''<br>&nbsp;AND DAY(appts.start)=''<br>&nbsp;AND patients.patient_id = appts.patient_id<br>&nbsp;AND appts.type = appt_types.appt_type_id<br><br> <hr>
Output for hhvm-3.12.0
Notice: Undefined variable: year in /in/3TqDc on line -1 Notice: Undefined variable: month in /in/3TqDc on line -1 Notice: Undefined variable: day in /in/3TqDc on line -1 <hr>SELECT patients.patient_id,patients.last_name,patients.first_name,appts.*,appt_types.type,appt_types.color,appt_types.bgcolor,DATE_FORMAT(appts.start,'%m/%d/%Y') AS date,DATE_FORMAT(appts.start,'%h:%i %p') AS time,TIMEDIFF(appts.end,appts.start) AS duration<br>&nbsp;FROM patients,appts,appt_types<br>&nbsp;WHERE appts.cancelled IS NULL<br>&nbsp;AND YEAR(appts.start)=''<br>&nbsp;AND MONTH(appts.start)=''<br>&nbsp;AND DAY(appts.start)=''<br>&nbsp;AND patients.patient_id = appts.patient_id<br>&nbsp;AND appts.type = appt_types.appt_type_id<br><br> <hr>
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: year in /in/3TqDc on line 34 Notice: Undefined variable: month in /in/3TqDc on line 35 Notice: Undefined variable: day in /in/3TqDc on line 36 <hr>SELECT patients.patient_id,patients.last_name,patients.first_name,appts.*,appt_types.type,appt_types.color,appt_types.bgcolor,DATE_FORMAT(appts.start,'%m/%d/%Y') AS date,DATE_FORMAT(appts.start,'%h:%i %p') AS time,TIMEDIFF(appts.end,appts.start) AS duration<br>&nbsp;FROM patients,appts,appt_types<br>&nbsp;WHERE appts.cancelled IS NULL<br>&nbsp;AND YEAR(appts.start)=''<br>&nbsp;AND MONTH(appts.start)=''<br>&nbsp;AND DAY(appts.start)=''<br>&nbsp;AND patients.patient_id = appts.patient_id<br>&nbsp;AND appts.type = appt_types.appt_type_id<br><br> <hr>
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/3TqDc on line 7
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/3TqDc on line 7
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/3TqDc on line 7
Process exited with code 255.