3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php ini_set('memory_limit', '-1'); // http://forrk.co.uk/blog/Finding-a-short-Twitter-Username-Mission-Impossible/1 function checkusername($username){ if(!empty($username) && $username != ''){ $url="http://twitter.com/".$username; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $return = curl_exec($ch); $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if($http_status == '404'){ echo 'Available: '.$username."\n"; } else{ // not available } }// if }// function checkusername($username) // http://stackoverflow.com/a/19067884/901502 function build_usernames($chars, $size, $combinations = array()){ // if it's the first iteration, the first set // of combinations is the same as the set of characters if(empty($combinations)){ $combinations = $chars; } // we're done if we're at size 1 if ($size == 1) { return $combinations; } // initialise array to put new values in $new_combinations = array(); // loop through existing combinations and character set to create strings foreach($combinations as $combination){ foreach($chars as $char){ $new_combinations[] = $combination . $char; }// foreach }// foreach // call same function again for the next iteration return build_usernames($chars, $size - 1, $new_combinations); }// function build_usernames($chars, $size, $combinations = array()) // set the possible chars to build the username from $possible_chars = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm'); // build the user name combinations for up to 4 char usernames $possible_usernames = build_usernames($possible_chars, 4); // loop through all usernames and check each with twitter foreach($possible_usernames as $username){ checkusername($username); }
based on ES1pT
Output for 7.0.0 - 7.1.7, 7.2.0
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/khDe6:9 Stack trace: #0 /in/khDe6(65): checkusername('1111') #1 {main} thrown in /in/khDe6 on line 9
Process exited with code 255.
Output for 7.1.10

Process exited with code 137.
Output for 5.6.28
Fatal error: Out of memory (allocated 259522560) (tried to allocate 72 bytes) in /in/khDe6 on line 48
Process exited with code 255.
Output for 5.3.18 - 5.6.21
Fatal error: Call to undefined function curl_init() in /in/khDe6 on line 9
Process exited with code 255.