3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php session_start(); // Zufaelligen captchastring erstellen function random_string() { $chars = 'ABCDEFGHKLMNPQRSTUVWXYZ23456789'; $string = ''; $i = 1; $max = 5; while ($i <= $max) { $char = substr($chars,rand(0,strlen($chars)-1),1); $string .= $char; $i++; } return $string; } // captcha code ausgeben function get_captcha() { $old = time()-(60*20); if (empty($_SESSION['captcha'])) return null; if ($_SESSION['captcha']['date'] < $old) return null; return $_SESSION['captcha']['code']; } // captcha erstellen function make_captcha() { unset($_SESSION['captcha']); $string = random_string(); $width = 200; $height = 75; $font = 'captcha.ttf'; $one = imagecreate($width,$height); $two = imagecreate($width,$height); $bgone = imagecolorallocate($one,0,0,0); $txtone = imagecolorallocate($one,255,255,255); $bgtwo = imagecolorallocate($two,255,255,255); $txttwo = imagecolorallocate($two, 0, 0, 0); imagettftext($one,32,0,10,$height-20,$txtone,$font,$string); $y = 0; while ($y < $height) { $x = 0; while ($x < $width) { $r = rand(1,2); if ($r == 1) { $dot = imagecolorat($one,$x,$y); if ($dot == 0) { imagesetpixel($two,$x,$y,$txttwo); imagesetpixel($one,$x,$y,$txtone); } else { imagesetpixel($one,$x,$y,$bgone); imagesetpixel($two,$x,$y,$txttwo); } } $x++; } $y++; } imagecolortransparent($one,$txtone); imagecolortransparent($two,$bgtwo); $old_content = ob_get_contents(); ob_clean(); imagepng($one); $imgone = ob_get_contents(); ob_clean(); imagepng($two); $imgtwo = ob_get_contents(); ob_clean(); echo $old_content; $_SESSION['captcha'] = array('code'=>$string,'date'=>time()); $audiostring = implode('+.', str_split($string)); return '<div style="background-image:url(data:image/png;base64,'. base64_encode($imgone).');background-repeat:no-repeat;background-color:#FFFFFF;width:'.($width).';"><img src="data:image/png;base64,'. base64_encode($imgtwo).'" border="0" /></div>' . '<audio controls autoplay style="width:200px;"><source src="data:audio/mpeg;base64,' . base64_encode(file_get_contents('http://translate.google.com/translate_tts?tl=de&q=' . $audiostring)) . '" type="audio/mpeg"></audio>'; } die(make_captcha());
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function imagecreate() in /in/sukBI:33 Stack trace: #0 /in/sukBI(80): make_captcha() #1 {main} thrown in /in/sukBI on line 33
Process exited with code 255.
Output for 5.2.3 - 5.6.28
Fatal error: Call to undefined function imagecreate() in /in/sukBI on line 33
Process exited with code 255.
Output for 5.0.0 - 5.2.2
Warning: session_start(): Cannot send session cookie - headers already sent in /in/sukBI on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/sukBI:2) in /in/sukBI on line 2 Fatal error: Call to undefined function imagecreate() in /in/sukBI on line 33
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Warning: session_start(): Cannot send session cookie - headers already sent in /in/sukBI on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/sukBI:2) in /in/sukBI on line 2 Fatal error: Call to undefined function: imagecreate() in /in/sukBI on line 33
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Warning: session_start(): Cannot send session cookie - headers already sent in /in/sukBI on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/sukBI:2) in /in/sukBI on line 2 Fatal error: Call to undefined function: imagecreate() in /in/sukBI on line 33
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cookie - headers already sent in /in/sukBI on line 2 Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cache limiter - headers already sent (output started at /in/sukBI:2) in /in/sukBI on line 2 Fatal error: Call to undefined function: imagecreate() in /in/sukBI on line 33