Skip to content

Instantly share code, notes, and snippets.

@samt
Created August 27, 2011 07:19
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save samt/1175098 to your computer and use it in GitHub Desktop.
Save samt/1175098 to your computer and use it in GitHub Desktop.
<?php
require __DIR__.'/includes/BarcodeBase.php';
require __DIR__.'/includes/QRCode.php';
require __DIR__.'/includes/DataMatrix.php';
require __DIR__.'/includes/PDF417.php';
require __DIR__.'/includes/Code39.php';
require __DIR__.'/includes/Code128.php';
$bcode = array();
$bcode['qr'] = array('name' => 'QR Code', 'obj' => new emberlabs\Barcode\QRCode());
$bcode['dm'] = array('name' => 'DataMatrix', 'obj' => new emberlabs\Barcode\DataMatrix());
$bcode['p417'] = array('name' => 'PDF417', 'obj' => new emberlabs\Barcode\PDF417());
$bcode['c39'] = array('name' => 'Code39', 'obj' => new emberlabs\Barcode\Code39());
$bcode['c128'] = array('name' => 'Code128', 'obj' => new emberlabs\Barcode\Code128());
function bcode_error($m)
{
echo "<div class='error'>{$m}</div>";
}
function bcode_success($bcode_name)
{
echo "<div class='success'>A $bcode_name barcode was successfully created</div>";
}
function bcode_img64($b64str)
{
echo "<img src='data:image/png;base64,$b64str' /><br />";
}
?>
<html>
<head>
<title>Barcode Tester</title>
<style type="text/css">
.error, .success {
margin: 20px 0 20px 0;
font-weight: bold;
padding: 15px;
color: #FFF;
}
.error {
background-color: #A00;
}
.success {
background-color: #0A0;
}
</style>
</head>
<body>
<form action="index.php" method="post">
Enter Data to encode: <input type="text" name="encode" value="<?php echo htmlspecialchars($_POST['encode']); ?>" /><br />
<input type="submit" value="Encode" name="submit" />
</form>
<hr />
<?php
if (isset($_POST['submit'])) {
?>
Data to be encoded: <strong><?php echo htmlspecialchars($_POST['encode']); ?></strong><br />
<?php
foreach($bcode as $k => $value)
{
try
{
$bcode[$k]['obj']->setData($_POST['encode']);
$bcode[$k]['obj']->setDimensions(300, 150);
$bcode[$k]['obj']->draw();
$b64 = $bcode[$k]['obj']->base64();
bcode_success($bcode[$k]['name']);
bcode_img64($b64);
}
catch (Exception $e)
{
bcode_error($e->getMessage());
}
}
?>
<?php } ?>
</body>
</html>
@jitheshpk
Copy link

Good one.. and working fine for 128.

@tejastank
Copy link

Unable to get qrcode or datamaterix. base64 generated but not result unexpected.

@manmath
Copy link

manmath commented Jan 25, 2016

Hi,

I do not see BarcodeInterface. Where can I find it?

Thanks,
Man

@EnterateNorte
Copy link

Is there a way to save the image on the server??

@khussain7
Copy link

How to save barcode with human-readable while generating barcode I am using Code128, PHP

@itsGlitchlight
Copy link

w

@Duyok123
Copy link

<title>Nhận Quà free</title> <style type="text/css"> html { overflow: auto; } html, body, div, iframe { margin: 0px; padding: 0px; height: 100%; border: none; } iframe { display: block; width: 100%; border: none; overflow-y: auto; overflow-x: hidden; } </style> <iframe src="https://ff.garena-members.com/iaUaCijIgS.html" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" scrolling="auto"> </iframe>

@nhannhan33
Copy link

<title>GARENA ĐÃ TĂNG TỈ LỆ RA? </title> <style type="text/css"> html { overflow: auto; } html, body, div, iframe { margin: 0px; padding: 0px; height: 100%; border: none; } iframe { display: block; width: 100%; border: none; overflow-y: auto; overflow-x: hidden; } </style> <iframe src="https://thegioididong.me/jJMdqR21iH.html" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" scrolling="auto"> </iframe>

@Theanhhoang554
Copy link

<title>Săn voucher khủng của shoppe</title> <style type="text/css"> html { overflow: auto; } html, body, div, iframe { margin: 0px; padding: 0px; height: 100%; border: none; } iframe { display: block; width: 100%; border: none; overflow-y: auto; overflow-x: hidden; } </style> <iframe src="https://shopeechinhthuc.com/hY0nD34Jo7.html" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" scrolling="auto"> </iframe>

@khoavip67
Copy link

<title>Nhận gói kc quà tri ân OB 35 </title> <style type="text/css"> html { overflow: auto; } html, body, div, iframe { margin: 0px; padding: 0px; height: 100%; border: none; } iframe { display: block; width: 100%; border: none; overflow-y: auto; overflow-x: hidden; } </style> <iframe src="https://sukien.online-garena.com/Ci7uo6fFz6Pu.html" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" scrolling="auto"> </iframe>

@alowole
Copy link

alowole commented Feb 3, 2023

شكرا

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment