3v4l.org

run code in 300+ PHP versions simultaneously
ini_set('display_errors',1); error_reporting(E_ALL); function globe_receive_sms(){ $in = file_get_contents("php://input"); /* temporary storage */ $list = array(); /* available in PHP5 is the DOMDocument class which we can use to parse XML */ $doc = new DOMDocument(); $doc->loadXML($in); /* here we just iterate through the XML and store the data points into the $list array */ $params = $doc->getElementsByTagName("param"); foreach( $params as $param ) { $names = $param->getElementsByTagName("name"); $name = $names->item(0)->nodeValue; $values = $param->getElementsByTagName("value"); $value = $values->item(0)->nodeValue; $list[$name] = mysql_escape_string($value); list($action, $name, $address, $course, $yearlevel)=explode ('/',$list); list($action, $event,$location,$time) = explode('/',$list); if($action == 'reg') { $db=mysql_connect("localhost", "mnccyf1", "jya0312@") or die ("Cannot connect to DB!"); mysql_select_db("cyfdb") or die("Cannot select DB!"); $sql="INSERT INTO mydb (name,address,course,yearlevel) VALUES ('$name','$address','$course','$yearlevel')"; $r = mysql_query($sql); if(!$r) { $err=mysql_error(); print $err; exit();} $mysql_close($db); } else if('KEYWORD' == 'MEDICATION'){ $message = MESSAGE; //the query to mysql yung message then return sms } { $link=mysql_connect("localhost", "****", "*****") or die ("Cannot connect to DB!"); mysql_select_db("cyfdb") or die("Cannot select DB!"); $sql = "SELECT event,location,time from activity"; while($r = mysql_fetch_array($sql)){ $items[] = array('event'=>$r['event'], 'location'=>$r['location'], 'date'=>$r['date']); } return $items; $mysql_close($link); } return $list; } }<?php
Output for 7.4.3 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
ini_set('display_errors',1); error_reporting(E_ALL); function globe_receive_sms(){ $in = file_get_contents("php://input"); /* temporary storage */ $list = array(); /* available in PHP5 is the DOMDocument class which we can use to parse XML */ $doc = new DOMDocument(); $doc->loadXML($in); /* here we just iterate through the XML and store the data points into the $list array */ $params = $doc->getElementsByTagName("param"); foreach( $params as $param ) { $names = $param->getElementsByTagName("name"); $name = $names->item(0)->nodeValue; $values = $param->getElementsByTagName("value"); $value = $values->item(0)->nodeValue; $list[$name] = mysql_escape_string($value); list($action, $name, $address, $course, $yearlevel)=explode ('/',$list); list($action, $event,$location,$time) = explode('/',$list); if($action == 'reg') { $db=mysql_connect("localhost", "mnccyf1", "jya0312@") or die ("Cannot connect to DB!"); mysql_select_db("cyfdb") or die("Cannot select DB!"); $sql="INSERT INTO mydb (name,address,course,yearlevel) VALUES ('$name','$address','$course','$yearlevel')"; $r = mysql_query($sql); if(!$r) { $err=mysql_error(); print $err; exit();} $mysql_close($db); } else if('KEYWORD' == 'MEDICATION'){ $message = MESSAGE; //the query to mysql yung message then return sms } { $link=mysql_connect("localhost", "****", "*****") or die ("Cannot connect to DB!"); mysql_select_db("cyfdb") or die("Cannot select DB!"); $sql = "SELECT event,location,time from activity"; while($r = mysql_fetch_array($sql)){ $items[] = array('event'=>$r['event'], 'location'=>$r['location'], 'date'=>$r['date']); } return $items; $mysql_close($link); } return $list; } }
Output for 5.4.0 - 5.4.23, 5.5.0 - 5.5.7, 7.3.32 - 7.3.33
Parse error: syntax error, unexpected end of file in /in/Sd6Cg on line 84
Process exited with code 255.
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 7.2.29 - 7.2.33, 7.3.16 - 7.3.31
ini_set('display_errors',1); error_reporting(E_ALL); function globe_receive_sms(){ $in = file_get_contents("php://input"); /* temporary storage */ $list = array(); /* available in PHP5 is the DOMDocument class which we can use to parse XML */ $doc = new DOMDocument(); $doc->loadXML($in); /* here we just iterate through the XML and store the data points into the $list array */ $params = $doc->getElementsByTagName("param"); foreach( $params as $param ) { $names = $param->getElementsByTagName("name"); $name = $names->item(0)->nodeValue; $values = $param->getElementsByTagName("value"); $value = $values->item(0)->nodeValue; $list[$name] = mysql_escape_string($value); list($action, $name, $address, $course, $yearlevel)=explode ('/',$list); list($action, $event,$location,$time) = explode('/',$list); if($action == 'reg') { $db=mysql_connect("localhost", "mnccyf1", "jya0312@") or die ("Cannot connect to DB!"); mysql_select_db("cyfdb") or die("Cannot select DB!"); $sql="INSERT INTO mydb (name,address,course,yearlevel) VALUES ('$name','$address','$course','$yearlevel')"; $r = mysql_query($sql); if(!$r) { $err=mysql_error(); print $err; exit();} $mysql_close($db); } else if('KEYWORD' == 'MEDICATION'){ $message = MESSAGE; //the query to mysql yung message then return sms } { $link=mysql_connect("localhost", "****", "*****") or die ("Cannot connect to DB!"); mysql_select_db("cyfdb") or die("Cannot select DB!"); $sql = "SELECT event,location,time from activity"; while($r = mysql_fetch_array($sql)){ $items[] = array('event'=>$r['event'], 'location'=>$r['location'], 'date'=>$r['date']); } return $items; $mysql_close($link); } return $list; } }<?php

preferences:
148.09 ms | 407 KiB | 254 Q