3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
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 5.4.0 - 5.5.7
Parse error: syntax error, unexpected end of file in /in/Sd6Cg on line 84
Process exited with code 255.
Output for 4.3.0 - 5.3.29
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