3v4l.org

run code in 300+ PHP versions simultaneously
<?php // 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); }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.1, 8.1.28, 8.2.18, 8.3.6
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/ES1pT on line 48
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/ES1pT on line 48
Process exited with code 255.
Output for 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Out of memory (allocated 29364224 bytes) (tried to allocate 16777224 bytes) in /in/ES1pT on line 48 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 8.1.2 - 8.1.27
Fatal error: Out of memory (allocated 23076864) (tried to allocate 16777224 bytes) in /in/ES1pT on line 48 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 8.0.13
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 67108872 bytes) in /in/ES1pT on line 48
Process exited with code 255.
Output for 5.4.10 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/ES1pT on line 48
Process exited with code 255.
Output for 5.4.2 - 5.4.9
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /in/ES1pT on line 48
Process exited with code 255.

preferences:
150.01 ms | 401 KiB | 257 Q