3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $file = date('dmY-His'); header("Content-type: text/csv"); header("Content-Disposition: attachment; filename=visitors-$file.csv"); header("Pragma: no-cache"); header("Expires: 0"); $sql = "select id, ip, server, time, date from visitors"; $res = mysql_query($sql); $data = array(); $data[] = array('id', 'ip', 'server', 'time', 'date'); while ($row = mysql_fetch_array($res)) { $data[] = array_values($row); } $output = fopen("php://output", "w"); foreach ($data as $val) { fputcsv($output, $val); } fclose($output);
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/MmkMW:9 Stack trace: #0 {main} thrown in /in/MmkMW on line 9
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Warning: supplied argument is not a valid MySQL-Link resource in /in/MmkMW on line 9 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /in/MmkMW on line 12 id,ip,server,time,date
Output for 5.0.0 - 5.6.28
Fatal error: Call to undefined function mysql_query() in /in/MmkMW on line 9
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /in/MmkMW on line 9 Warning: mysql_query(): A link to the server could not be established in /in/MmkMW on line 9 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /in/MmkMW on line 12 Fatal error: Call to undefined function: fputcsv() in /in/MmkMW on line 18
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /in/MmkMW on line 9 Warning: mysql_query(): A link to the server could not be established in /in/MmkMW on line 9 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /in/MmkMW on line 12 Fatal error: Call to undefined function: fputcsv() in /in/MmkMW on line 18
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: mysql_query() [http://www.php.net/function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /in/MmkMW on line 9 Warning: mysql_query() [http://www.php.net/function.mysql-query]: A link to the server could not be established in /in/MmkMW on line 9 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /in/MmkMW on line 12 Fatal error: Call to undefined function: fputcsv() in /in/MmkMW on line 18