3v4l.org

run code in 300+ PHP versions simultaneously
<?php header("Content-type: image/gif"); $cells = array ( liked=>200, hated=>400, indifferent=>900 ); $max = max( $cells ); $total = count ( $cells ); $totalwidth = 300; $totalheight = 200; $xgutter = 20; // left/right margin $ygutter = 20; // top/bottom margin $internalgap = 10; // space between cells $bottomspace = 30; // gap at the bottom (in addition to margin) $font = "ARIALBD.TTF"; $graphCanX = ( $totalwidth - $xgutter*2 ); $graphCanY = ( $totalheight - $ygutter*2 - $bottomspace );// starting draw position x - axis $posX = $xgutter; // starting draw pos - y - axis $posY = $totalheight - $ygutter - $bottomspace; $cellwidth = (int) (( $graphCanX - ( $internalgap * ( $total-1 ) )) / $total) ; $textsize = (int)($bottomspace); // adjust font size while ( list( $key, $val ) = each ( $cells ) ) { while ( 1 ) { $box = ImageTTFbBox( $textsize, 0, $font, $key ); $textWidth = abs( $box[2] ); if ( $textWidth < $cellwidth ) break; $textsize--; } } $image = imagecreate( $totalwidth, $totalheight ); $red = ImageColorAllocate($image, 255, 0, 0); $blue = ImageColorAllocate($image, 0, 0, 255 ); $black = ImageColorAllocate($image, 0, 0, 0 ); $grey = ImageColorAllocate($image, 100, 100, 100 ); reset ($cells); while ( list( $key, $val ) = each ( $cells ) ) { $cellheight = (int) (($val/$max) * $graphCanY); $center = (int)($posX+($cellwidth/2)); imagefilledrectangle( $image, $posX, ($posY-$cellheight), ($posX+$cellwidth), $posY, $blue ); $box = ImageTTFbBox( $textsize, 0, $font, $key ); $tw = $box[2]; ImageTTFText( $image, $textsize, 0, ($center-($tw/2)), ($totalheight-$ygutter), $black, $font, $key ); $posX += ( $cellwidth + $internalgap); } imagegif( $image );
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Undefined constant "liked" in /in/bfOcZ:3 Stack trace: #0 {main} thrown in /in/bfOcZ on line 3
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Warning: Use of undefined constant liked - assumed 'liked' (this will throw an Error in a future version of PHP) in /in/bfOcZ on line 3 Warning: Use of undefined constant hated - assumed 'hated' (this will throw an Error in a future version of PHP) in /in/bfOcZ on line 3 Warning: Use of undefined constant indifferent - assumed 'indifferent' (this will throw an Error in a future version of PHP) in /in/bfOcZ on line 3 Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /in/bfOcZ on line 20 Fatal error: Uncaught Error: Call to undefined function ImageTTFbBox() in /in/bfOcZ:24 Stack trace: #0 {main} thrown in /in/bfOcZ on line 24
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Warning: Use of undefined constant liked - assumed 'liked' (this will throw an Error in a future version of PHP) in /in/bfOcZ on line 3 Warning: Use of undefined constant hated - assumed 'hated' (this will throw an Error in a future version of PHP) in /in/bfOcZ on line 3 Warning: Use of undefined constant indifferent - assumed 'indifferent' (this will throw an Error in a future version of PHP) in /in/bfOcZ on line 3 Fatal error: Uncaught Error: Call to undefined function ImageTTFbBox() in /in/bfOcZ:24 Stack trace: #0 {main} thrown in /in/bfOcZ on line 24
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25
Notice: Use of undefined constant liked - assumed 'liked' in /in/bfOcZ on line 3 Notice: Use of undefined constant hated - assumed 'hated' in /in/bfOcZ on line 3 Notice: Use of undefined constant indifferent - assumed 'indifferent' in /in/bfOcZ on line 3 Fatal error: Uncaught Error: Call to undefined function ImageTTFbBox() in /in/bfOcZ:24 Stack trace: #0 {main} thrown in /in/bfOcZ on line 24
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Notice: Use of undefined constant liked - assumed 'liked' in /in/bfOcZ on line 3 Notice: Use of undefined constant hated - assumed 'hated' in /in/bfOcZ on line 3 Notice: Use of undefined constant indifferent - assumed 'indifferent' in /in/bfOcZ on line 3 Fatal error: Call to undefined function ImageTTFbBox() in /in/bfOcZ on line 24
Process exited with code 255.

preferences:
166.57 ms | 402 KiB | 198 Q