3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function generateRandomName($minLength, $maxLength, $alphaNumericOnly = false) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; if (!$alphaNumericOnly) $chars .= ' '; $randomString = ''; $length = mt_rand($minLength, $maxLength); for ($i = 0; $i < $length; $i++) { $randomString .= $chars[rand(0, strlen($chars) - 1)]; } return $randomString; } $time = microtime(true); $i=0; while($i < 10000) { $i++; $this->generateRandomName(10, 18); } $time = microtime(true) - $time; echo 'took ' . number_format($time, 3);
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/lk9Iv:23 Stack trace: #0 {main} thrown in /in/lk9Iv on line 23
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: $this is null in /in/lk9Iv on line 23
Process exited with code 255.
Output for 5.3.28 - 5.3.29, 5.4.18 - 5.6.28
Fatal error: Using $this when not in object context in /in/lk9Iv on line 23
Process exited with code 255.
Output for 5.0.0 - 5.3.27, 5.4.0 - 5.4.17
Fatal error: Using $this when not in object context in /in/M4rVQ on line 23
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Call to a member function on a non-object in /in/M4rVQ on line 23
Process exited with code 255.
Output for 4.3.1
Fatal error: Call to a member function on a non-object in /in/M4rVQ on line 23
Output for 4.3.0
Fatal error: Call to a member function on a non-object in /in/lk9Iv on line 23