示例#1
0
 public function encode($intext, $outfile = false)
 {
     $code = new QRcode();
     if ($this->eightbit) {
         $code->encodeString8bit($intext, $this->version, $this->level);
     } else {
         $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
     }
     QRtools::markTime('after_encode');
     if ($outfile !== false) {
         file_put_contents($outfile, join("\n", QRtools::binarize($code->data)));
     } else {
         return QRtools::binarize($code->data);
     }
 }
<?php

include '../lib/full/qrlib.php';
// now the fun begins, we use code generating features of library
// outputs raw code table, but it is not 1 & 0, lib uses more descriptive
// context related bit markers
$codeContents = '12345ABCDE';
$version = 0;
// will be autodetected
$eccLevel = QR_ECLEVEL_L;
$encodingHint = QR_MODE_8;
$caseSensitive = false;
$code = new QRcode();
$code->encodeString($codeContents, $version, $eccLevel, $encodingHint, $caseSensitive);
echo '<pre>';
foreach ($code->data as $line) {
    echo bin2hex($line);
    echo '<br/>';
}
echo '</pre>';