3v4l.org

run code in 300+ PHP versions simultaneously
<? $filexml='data.xml'; preg_match("/([a-zA-Z0-9_-]+).([a-zA-Z0-9]+)/", $filexml, $extension); //$timestamp = date("Y-m-d_H:i:s"); $timestamp = time(); //$timestamp gets current time $myFile = data.$timestamp.".".$extension[2]; echo $myFile; file_put_contents($myFile, file_get_contents("input.txt")); $mycsvFile = "orderData.".$timestamp.".csv"; // timestamp to file name echo $mycsvFile; if (file_exists($myFile)) { $xml = simplexml_load_file($myFile); $f = fopen($mycsvFile, 'w'); // open and write to file createCsv($xml, $f); fclose($f); } function createCsv($xml,$f) { foreach ($xml->children() as $item) { $hasChild = (count($item->children()) > 0)?true:false; if( ! $hasChild) { $put_arr = array($item->getName(),$item); fputcsv($f, $put_arr ,',','"'); } else { createCsv($item, $f); } } } ?>
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.1.26 - 7.1.33, 7.2.17 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.16, 8.3.0 - 8.3.3
<? $filexml='data.xml'; preg_match("/([a-zA-Z0-9_-]+).([a-zA-Z0-9]+)/", $filexml, $extension); //$timestamp = date("Y-m-d_H:i:s"); $timestamp = time(); //$timestamp gets current time $myFile = data.$timestamp.".".$extension[2]; echo $myFile; file_put_contents($myFile, file_get_contents("input.txt")); $mycsvFile = "orderData.".$timestamp.".csv"; // timestamp to file name echo $mycsvFile; if (file_exists($myFile)) { $xml = simplexml_load_file($myFile); $f = fopen($mycsvFile, 'w'); // open and write to file createCsv($xml, $f); fclose($f); } function createCsv($xml,$f) { foreach ($xml->children() as $item) { $hasChild = (count($item->children()) > 0)?true:false; if( ! $hasChild) { $put_arr = array($item->getName(),$item); fputcsv($f, $put_arr ,',','"'); } else { createCsv($item, $f); } } } ?>
Output for 8.0.13
Fatal error: Uncaught Error: Undefined constant "data" in /in/ARBW5:6 Stack trace: #0 {main} thrown in /in/ARBW5 on line 6
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.33
Warning: Use of undefined constant data - assumed 'data' (this will throw an Error in a future version of PHP) in /in/ARBW5 on line 6 data1400832854.xml Warning: file_get_contents(input.txt): failed to open stream: No such file or directory in /in/ARBW5 on line 8 Warning: file_put_contents(data1400832854.xml): failed to open stream: Read-only file system in /in/ARBW5 on line 8 orderData.1400832854.csv
Output for 7.2.6
Warning: Use of undefined constant data - assumed 'data' (this will throw an Error in a future version of PHP) in /in/ARBW5 on line 6 data1400832854.xml Warning: file_get_contents(): open_basedir restriction in effect. File(input.txt) is not within the allowed path(s): (/tmp:/in) in /in/ARBW5 on line 8 Warning: file_get_contents(input.txt): failed to open stream: Operation not permitted in /in/ARBW5 on line 8 Warning: file_put_contents(): open_basedir restriction in effect. File(data1400832854.xml) is not within the allowed path(s): (/tmp:/in) in /in/ARBW5 on line 8 Warning: file_put_contents(data1400832854.xml): failed to open stream: Operation not permitted in /in/ARBW5 on line 8 orderData.1400832854.csv Warning: file_exists(): open_basedir restriction in effect. File(data1400832854.xml) is not within the allowed path(s): (/tmp:/in) in /in/ARBW5 on line 13
Output for 7.2.0
Warning: Use of undefined constant data - assumed 'data' (this will throw an Error in a future version of PHP) in /in/ARBW5 on line 6 data1400832854.xml Warning: file_get_contents(input.txt): failed to open stream: No such file or directory in /in/ARBW5 on line 8 Warning: file_put_contents(data1400832854.xml): failed to open stream: Permission denied in /in/ARBW5 on line 8 orderData.1400832854.csv
Output for 7.1.20
Notice: Use of undefined constant data - assumed 'data' in /in/ARBW5 on line 6 data1400832854.xml Warning: file_get_contents(): open_basedir restriction in effect. File(input.txt) is not within the allowed path(s): (/tmp:/in) in /in/ARBW5 on line 8 Warning: file_get_contents(input.txt): failed to open stream: Operation not permitted in /in/ARBW5 on line 8 Warning: file_put_contents(): open_basedir restriction in effect. File(data1400832854.xml) is not within the allowed path(s): (/tmp:/in) in /in/ARBW5 on line 8 Warning: file_put_contents(data1400832854.xml): failed to open stream: Operation not permitted in /in/ARBW5 on line 8 orderData.1400832854.csv Warning: file_exists(): open_basedir restriction in effect. File(data1400832854.xml) is not within the allowed path(s): (/tmp:/in) in /in/ARBW5 on line 13
Output for 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.10
Notice: Use of undefined constant data - assumed 'data' in /in/ARBW5 on line 6 data1400832854.xml Warning: file_get_contents(input.txt): failed to open stream: No such file or directory in /in/ARBW5 on line 8 Warning: file_put_contents(data1400832854.xml): failed to open stream: Permission denied in /in/ARBW5 on line 8 orderData.1400832854.csv

preferences:
257.96 ms | 403 KiB | 374 Q