3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function randomAlphaNum($length){ $alphNums = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; $newString = str_shuffle(str_repeat($alphNums, rand(1, $length))); return substr($newString, rand(0,strlen($newString)-$length), $length); } $domain = 'drmouse.com.ar'; $opt = array( CURLOPT_HEADER => 0, CURLOPT_URL => 'http://namey.muffinlabs.com/name.json?count=10&frequency=all&with_surname=true', CURLOPT_RETURNTRANSFER => 1 ); $ch = curl_init(); curl_setopt_array($ch, $opt); $results = curl_exec($ch); curl_close($ch); $results = json_decode($results); foreach ($results as $i => $name) { $fullname = explode(' ', $name); $names['doc'][] = strtolower("{$fullname[0]}{$fullname[1]}") . "@{$domain}"; $names['1pa'][] = "{$names['doc'][$i]} " . randomAlphaNum(18); $names['csv'][] = str_replace(' ', ",{$fullname[0]},{$fullname[1]},", $names['1pa'][$i]); } foreach (array('csv', '1pa', 'doc') as $place) { echo "<p><strong>{$place}:</strong></p>\n<ul>"; foreach ($names[$place] as $name) { echo "<li>{$name}</li>\n"; } echo '</ul>'; }
Output for 7.0.0 - 7.1.0
Notice: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' in /in/E22an on line 10 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/E22an on line 11 Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/E22an on line 12 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/E22an:14 Stack trace: #0 {main} thrown in /in/E22an on line 14
Process exited with code 255.
Output for hhvm-3.12.0
Warning: Invalid argument supplied for foreach() in /in/E22an on line -1 <p><strong>csv:</strong></p> <ul> Notice: Undefined variable: names in /in/E22an on line -1 Warning: Invalid argument supplied for foreach() in /in/E22an on line -1 </ul><p><strong>1pa:</strong></p> <ul> Notice: Undefined variable: names in /in/E22an on line -1 Warning: Invalid argument supplied for foreach() in /in/E22an on line -1 </ul><p><strong>doc:</strong></p> <ul> Notice: Undefined variable: names in /in/E22an on line -1 Warning: Invalid argument supplied for foreach() in /in/E22an on line -1 </ul>
Output for hhvm-3.10.0
Warning: Invalid argument supplied for foreach() in /in/E22an on line 25 <p><strong>csv:</strong></p> <ul> Notice: Undefined variable: names in /in/E22an on line 29 Warning: Invalid argument supplied for foreach() in /in/E22an on line 32 </ul><p><strong>1pa:</strong></p> <ul> Notice: Undefined variable: names in /in/E22an on line 29 Warning: Invalid argument supplied for foreach() in /in/E22an on line 32 </ul><p><strong>doc:</strong></p> <ul> Notice: Undefined variable: names in /in/E22an on line 29 Warning: Invalid argument supplied for foreach() in /in/E22an on line 32 </ul>
Output for 5.0.0 - 5.6.28
Notice: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' in /in/E22an on line 10 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/E22an on line 11 Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/E22an on line 12 Fatal error: Call to undefined function curl_init() in /in/E22an on line 14
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Notice: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' in /in/E22an on line 10 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/E22an on line 11 Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/E22an on line 12 Fatal error: Call to undefined function: curl_init() in /in/E22an on line 14
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Notice: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' in /in/E22an on line 10 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/E22an on line 11 Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/E22an on line 12 Fatal error: Call to undefined function: curl_init() in /in/E22an on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' in /in/E22an on line 10 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/E22an on line 11 Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/E22an on line 12 Fatal error: Call to undefined function: curl_init() in /in/E22an on line 14