3v4l.org

run code in 300+ PHP versions simultaneously
<?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.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
<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 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.3.11, 4.4.0 - 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.

preferences:
259.67 ms | 401 KiB | 456 Q