pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

PHP pastebin - collaborative debugging tool View Help


Posted by vkrmsv on Fri 19 Sep 17:23
report abuse | download | new post

  1. <?php
  2.  
  3. function convert_text_image($text_input)
  4. {
  5. $my_img = imagecreate( 290, 18 );
  6. $background = imagecolorallocate( $my_img, 255, 255, 255 );
  7. $text_colour = imagecolorallocate( $my_img, 0, 0, 0 );
  8. imagestring( $my_img, 4, 0, 0, $text_input,$text_colour );
  9. ob_start(); // This prevents the imagegif function from outputting to the browser.                                                            
  10. imagegif($my_img);
  11. $img_out = ob_get_contents(); // This gets the raw data of the image.                                                                        
  12. ob_end_clean(); // Clear all output till now                                                                                                  
  13.  $img_out = chunk_split(base64_encode($img_out)); // Encodes the data so that we can display this as a raw image on the browser.              
  14. $string = "\"data: image/gif;base64,".$img_out."\"";
  15. echo "<img src=$string />";
  16.  imagedestroy( $my_img ); //Free resources.                                                                                                  
  17. }
  18.  
  19.  
  20. $text = "example@example.com";
  21. convert_text_image($text);
  22.  
  23. ?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post