Пример #1
0
 public static function terminal($text, $level = Constants::QR_ECLEVEL_L, $size = 3, $margin = 4)
 {
     $backColor = "  ";
     $foreColor = "  ";
     $enc = QRencode::factory($level, $size, $margin);
     $qrcode = $enc->encode($text, false);
     $output = '';
     foreach ($qrcode as $k => $qr) {
         $len = strlen($qr);
         $border = str_repeat($foreColor, $len + 2);
         if ($k === 0) {
             $output .= $border . "\n";
         }
         $curLine = '';
         for ($i = 0; $i < strlen($qr); $i++) {
             $curLine .= $qr[$i] ? $backColor : $foreColor;
         }
         $output .= $foreColor . $curLine . $foreColor . "\n";
         if ($k === $len - 1) {
             $output .= $border . "\n";
         }
     }
     return $output;
 }
Пример #2
0
 public static function raw($text, $outfile = false, $level = Constants::QR_ECLEVEL_L, $size = 3, $margin = 4)
 {
     $enc = QRencode::factory($level, $size, $margin);
     return $enc->encodeRAW($text, $outfile);
 }