3v4l.org

run code in 300+ PHP versions simultaneously
<?php define("STATE_ID","3"); define("DATA_CACHE_TIMEOUT","9999"); class ImportController extends Controller { public function actionIndex() { $t1=date("r"); $ts1=microtime(true); $tot=0; echo "\r\n<p> ******** Started at $t1 ******** </p>\r\n"; $connection = Yii::app()->db; $command = $connection->createCommand('SELECT * FROM seccsirsa LIMIT 0,10'); $rows = $command->queryAll(); //executes the SQL statement and returns the first row of the //$res = array(); foreach ($rows as $row) { extract($row); echo "\r\n<p>Full Name: $Name_en ($Name_h) </p>\r\n"; //echo "<br /> ".$this->getDistId($District."DEL"); echo "<br /> ".$this->getDistId($District); } $t2=date("r"); $ts2=microtime(true); $diff=($ts2-$ts1); echo "\r\n<p> ******** Stopped at $t2 ******** </p>\r\n"; echo "\r\n<p> ******** Total Execution Time: $diff microseconds ******** </p>\r\n"; echo "\r\n<p> ******** Total Records Imported: $tot ******** </p>\r\n"; } private function getDistId($District){ //Select if record exists $District=trim(strtolower($District)); $connection = Yii::app()->db; $connection->active=true; $command = $connection->createCommand("SELECT LR_ID FROM tblLandRegion WHERE lower(LR_Name) = '$District' AND LR_Type='District' "); $row = $command->queryRow(); //If no record found if($row===false){ //Insert record in DB (Master Table) $command = $connection->createCommand("INSERT INTO tblLandRegion (LR_Name,LR_Type) VALUES('$District', 'District') "); $rowCount=$command->execute(); if($rowCount==0){ die("FATAL ERROR 0x01: Failed to insert $District in Master table :: ".__FILE__." at line nunber ".__LINE__); } else{ //Cache and Return the PK/ID of the new inserted record. $row = Yii::app()->cache->get('cache_'.$District."_".STATE_ID); if (($row === false) || row($res)) { $District=trim(strtolower($District)); $connection = Yii::app()->db; $command = $connection->createCommand("SELECT LR_ID FROM tblLandRegion WHERE lower(LR_Name) = '$District' AND LR_Type='District' ORDER BY LR_ID DESC"); $row = $command->queryRow(); Yii::app()->cache->set('cache_'.$District."_".STATE_ID, $row, DATA_CACHE_TIMEOUT); } $District_ID=$row['LR_ID']; //Insert record in DB (Reference Table) $command = $connection->createCommand("INSERT INTO tblDistrict (District_ID, State_ID) VALUES('$District_ID', '".STATE_ID."') "); $rowCount=$command->execute(); if($rowCount==0){ die("FATAL ERROR 0x02: Failed to insert $District in Reference table :: ".__FILE__." at line nunber ".__LINE__); } return $District_ID; } } else{ //Return the PK/ID of the record. return $row['LR_ID']; } } } ?>
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.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
Fatal error: Class 'Controller' not found in /in/9q9JV on line 6
Process exited with code 255.
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/9q9JV on line 8
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/9q9JV on line 8
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/9q9JV on line 8
Process exited with code 255.

preferences:
169.76 ms | 401 KiB | 210 Q