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)='2014'" . " AND MONTH(appts.start)='04'" . " AND DAY(appts.start)='1'" . " AND patients.patient_id = appts.patient_id" . " AND appts.type = appt_types.appt_type_id" . " AND (appts.type='4'" . " OR appts.type='5'" . " OR appts.type='6'" . " OR appts.type='7'" . " OR appts.type='8'" . " OR appts.type='9'" . " OR appts.type='10'" . " OR appts.type='11'" . " OR appts.type='12'" . " OR appts.type='13'" . " OR appts.type='15'" . " OR appts.type='16'" . " OR appts.type='17'" . " )" . " ORDER BY appts.start" . " ASC LIMIT 0,6"; $q2t = new query2text(); echo "<hr>" . $q2t->convert($query) . "<hr>\n";
Output for 5.0.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
<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)='2014'<br>&nbsp;AND MONTH(appts.start)='04'<br>&nbsp;AND DAY(appts.start)='1'<br>&nbsp;AND patients.patient_id = appts.patient_id<br>&nbsp;AND appts.type = appt_types.appt_type_id<br>&nbsp;AND (appts.type='4' OR appts.type='5' OR appts.type='6' OR appts.type='7' OR appts.type='8' OR appts.type='9' OR appts.type='10' OR appts.type='11' OR appts.type='12' OR appts.type='13' OR appts.type='15' OR appts.type='16' OR appts.type='17' )<br>&nbsp;ORDER BY appts.start ASC LIMIT 0,6<br><br> <hr>
Output for hhvm-3.10.0

Process exited with code 153.
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/4L5uL 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/4L5uL 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/4L5uL on line 7
Process exited with code 255.