phpimageheaderbroken-imagecode39

Barcode39 PHP class stops working


I don't know what happened, but barcode39.php class is just not working anymore. If You follow the link http://eventstar.hu/api/code39/BARCODE-123456789101 , You can see that there's a broken image link, however, the image was generated directly to the browser by the PHP class with the correct headers (image/gif). If you view the source (type "view-source:" before the URL in Chrome), You can see that the image data was here, starting wih GIF...

The code was not too complex. page_attr[1] is the end of the URL, in this case : BARCODE-123456789101. The following snippet was wrapped inside if($page_attr[0]=="code39"), but it's irrelevant, because it's true.

include("include/barcode39/barcode39.class.php");
$bc = new Barcode39($page_attr[1]);
$bc->barcode_text_size = 2;
$bc->barcode_bar_thick = 2;
$bc->barcode_bar_thin = 1;
$bc->barcode_use_dynamic_width = false;
$bc->barcode_width = 300;
$bc->barcode_padding = 7;
$bc->draw();
exit;

Can a PHP update cause the problem? Or something is wrong with my code? I don't touch these files weeks ago, hovewer the barcode generator doesn't work anymore... Any suggestions?


Solution

  • Finally, someone pointed out that the encoding of the PHP file itself can cause problems. So everyone facing this problem, make sure You saved the file in UTF-8 without BOM!