当前位置: 首页>>代码示例>>PHP>>正文


PHP QRcode::text方法代码示例

本文整理汇总了PHP中QRcode::text方法的典型用法代码示例。如果您正苦于以下问题:PHP QRcode::text方法的具体用法?PHP QRcode::text怎么用?PHP QRcode::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QRcode的用法示例。


在下文中一共展示了QRcode::text方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: qrencode

function qrencode($s, $size = 1, $quality = 'M', $fg = false, $bg = false, $margin = 0)
{
    $ql = array('L' => QR_ECLEVEL_L, 'M' => QR_ECLEVEL_M, 'Q' => QR_ECLEVEL_Q, 'H' => QR_ECLEVEL_H);
    if (!$s or !is_numeric($size) or !is_numeric($margin) or !$quality or !array_key_exists($quality, $ql) or $fg and !validate_color($fg) or $bg and !validate_color($bg)) {
        return false;
    }
    if ($size < 1) {
        $size = 1;
    }
    if ($margin < 0) {
        $margin = 0;
    }
    $q = $ql[$quality];
    $frame = @QRcode::text($s, false, $q, 1, 0);
    if (!$frame) {
        return false;
    }
    $h = count($frame);
    $w = strlen($frame[0]);
    $img = imagecreatetruecolor($w + 2 * $margin, $h);
    $qrimg = imagecreatetruecolor($w * $size + 2 * $margin, $h * $size + 2 * $margin);
    if ($bg) {
        $rgb = str_split($bg[0] == '#' ? substr($bg, 1, 6) : $bg, 2);
        $r = hexdec($rgb[0]);
        $g = hexdec($rgb[1]);
        $b = hexdec($rgb[2]);
    } else {
        $r = $g = $b = 255;
    }
    $bg = imagecolorallocate($img, $r, $g, $b);
    imagefill($img, 0, 0, $bg);
    $bg = imagecolorallocate($qrimg, $r, $g, $b);
    imagefill($qrimg, 0, 0, $bg);
    if ($fg) {
        $rgb = str_split($fg[0] == '#' ? substr($fg, 1, 6) : $fg, 2);
        $r = hexdec($rgb[0]);
        $g = hexdec($rgb[1]);
        $b = hexdec($rgb[2]);
    } else {
        $r = $g = $b = 0;
    }
    $fg = imagecolorallocate($img, $r, $g, $b);
    for ($y = 0; $y < $h; $y++) {
        for ($x = 0; $x < $w; $x++) {
            if ($frame[$y][$x] == '1') {
                imagesetpixel($img, $x, $y, $fg);
            }
        }
    }
    imagecopyresized($qrimg, $img, $margin, $margin, 0, 0, $w * $size, $h * $size, $w, $h);
    imagedestroy($img);
    ob_start();
    imagepng($qrimg);
    $png = ob_get_clean();
    imagedestroy($qrimg);
    return $png;
}
开发者ID:RazorMarx,项目名称:izend,代码行数:57,代码来源:qrencode.php

示例2: tcpdfBarcodeArray

 public static function tcpdfBarcodeArray($code, $mode = 'QR,L', $tcPdfVersion = '4.5.037')
 {
     $barcode_array = array();
     if (!is_array($mode)) {
         $mode = explode(',', $mode);
     }
     $eccLevel = 'L';
     if (count($mode) > 1) {
         $eccLevel = $mode[1];
     }
     $qrTab = QRcode::text($code, false, $eccLevel);
     $size = count($qrTab);
     $barcode_array['num_rows'] = $size;
     $barcode_array['num_cols'] = $size;
     $barcode_array['bcode'] = array();
     foreach ($qrTab as $line) {
         $arrAdd = array();
         foreach (str_split($line) as $char) {
             $arrAdd[] = $char == '1' ? 1 : 0;
         }
         $barcode_array['bcode'][] = $arrAdd;
     }
     return $barcode_array;
 }
开发者ID:norain2050,项目名称:xingkang,代码行数:24,代码来源:qrtools.php

示例3: renderQRCode

 /**
  * @phutil-external-symbol class QRcode
  */
 private function renderQRCode($uri)
 {
     $root = dirname(phutil_get_library_root('phabricator'));
     require_once $root . '/externals/phpqrcode/phpqrcode.php';
     $lines = QRcode::text($uri);
     $total_width = 240;
     $cell_size = floor($total_width / count($lines));
     $rows = array();
     foreach ($lines as $line) {
         $cells = array();
         for ($ii = 0; $ii < strlen($line); $ii++) {
             if ($line[$ii] == '1') {
                 $color = '#000';
             } else {
                 $color = '#fff';
             }
             $cells[] = phutil_tag('td', array('width' => $cell_size, 'height' => $cell_size, 'style' => 'background: ' . $color), '');
         }
         $rows[] = phutil_tag('tr', array(), $cells);
     }
     return phutil_tag('table', array('style' => 'margin: 24px auto;'), $rows);
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:25,代码来源:PhabricatorTOTPAuthFactor.php

示例4: join

</td>
  </tr>
  <tr border="0">
    <td colspan="6">Diagnostico:</td>
  </tr>
  <tr border="0">
    <td height="95" colspan="6">
    <div style="float:left;">
   <!--[if (IE )]>
   	<?php 
// print_r('menor o igual a 8');
include '../autogestion/qrcode/qrlib.php';
// text output   ie8 o inferior
$codeContents = $numero_orden . ' 22';
// generating
$text = QRcode::text($codeContents);
$raw = join("<br/>", $text);
$raw = strtr($raw, array('0' => '<span style="color:white">&#9608;&#9608;</span>', '1' => '&#9608;&#9608;'));
echo '<tt style="font-size:3px">' . $raw . '</tt>';
?>
   <![endif]-->
   
<!--[if !IE]><!-->
		<?php 
echo '<img  src="qr.php" />';
//<![endif]-->
?>
    <!-- <![endif]-->

    </div>
    <div style="float:right">
开发者ID:sergiodcaballero,项目名称:smaunam,代码行数:31,代码来源:ordenes.php

示例5: qrtest

 public static function qrtest()
 {
     // Include only this file, remaining required files will be included from it
     if (!class_exists("qrstr", FALSE)) {
         require_once PATH_PHPQRCODE . "/qrlib.php";
     }
     //write code into file, Error corection lecer is lowest, L (one form: L,M,Q,H)
     //each code square will be 4x4 pixels (4x zoom)
     //code will have 2 code squares white boundary around
     if (1) {
         // Error correction level L : About 7% or less errors can be corrected.
         // Error correction level M : About 15% or less errors can be corrected.
         // Error correction level Q : About 25% or less errors can be corrected.
         // Error correction level H : About 30% or less errors can be corrected.
         $text = "http://www.nordita.org/guest/";
         $filetype = "png";
         // "png","svg","eps","txt"
         if (!in_array($filetype, array("png", "svg", "eps", "txt"))) {
             return FALSE;
         }
         $level = "H";
         // "L" (default) ,"M", "Q", "H"
         $pixelsize = 16;
         // pixel size of each code square
         $margin = 4;
         // boundary width in number of code squares
         $saveandprint = FALSE;
         // TRUE = save to file and display in browser; FALSE = save to file only; redundant if $outfile=FALSE
         $back_color = 0xffffff;
         $fore_color = 0x0;
         $cmyk = TRUE;
         $filename = "qrcode";
         $outfile = PATH_PHPQRCACHE . $filename . "." . $filetype;
         // full file path or FALSE (only output on screen)
         //$outfile      = FALSE;
         switch ($filetype) {
             case "png":
                 QRcode::png($text, $outfile, $level, $pixelsize, $margin, $saveandprint, $back_color, $fore_color);
                 break;
             case "eps":
                 QRcode::eps($text, $outfile, $level, $pixelsize, $margin, $saveandprint, $back_color, $fore_color, $cmyk);
                 break;
             case "svg":
                 QRcode::svg($text, $outfile, $level, $pixelsize, $margin, $saveandprint, $back_color, $fore_color);
                 break;
             case "txt":
                 QRcode::text($text, $outfile, $level, $pixelsize, $margin);
                 // black = "1", white = "0"
                 break;
         }
         // end switch
     }
     //same as above but outputs file directly into browser (with appr. header etc.)
     //all other settings are default
     //WARNING! it should be FIRST and ONLY output generated by script, otherwise
     //rest of output will land inside PNG binary, breaking it for sure
     if (0) {
         QRcode::png("PHP QR Code :)");
     }
     //show benchmark
     if (0) {
         QRtools::timeBenchmark();
     }
     //rebuild cache
     if (0) {
         QRtools::buildCache();
     }
     //code generated in text mode - as a binary table
     //then displayed out as HTML using Unicode block building chars :)
     if (0) {
         $qr = new QRencode();
         $tab = $qr->encode('PHP QR Code :)');
         QRspec::debug($tab, true);
     }
 }
开发者ID:,项目名称:,代码行数:75,代码来源:

示例6: qrImg

 private function qrImg($orderid)
 {
     include Doo::conf()->SITE_PATH . 'protected/module/default/class/phpqrcode/qrlib.php';
     $codeContents = $orderid;
     $tempDir = Doo::conf()->QR_FILE_PATH;
     $fileName = $orderid . '.jpg';
     $outerFrame = 0;
     $pixelPerPoint = 5;
     $jpegQuality = 95;
     // generating frame
     $frame = QRcode::text($codeContents, false, QR_ECLEVEL_M);
     // rendering frame with GD2 (that should be function by real impl.!!!)
     $h = count($frame);
     $w = strlen($frame[0]);
     $imgW = $w + 3 * $outerFrame;
     $imgH = $h + 3 * $outerFrame;
     $base_image = imagecreate($imgW, $imgH);
     $col[0] = imagecolorallocate($base_image, 255, 255, 255);
     // BG, white
     $col[1] = imagecolorallocate($base_image, 0, 0, 0);
     // FG, black blue
     imagefill($base_image, 0, 0, $col[0]);
     for ($y = 0; $y < $h; $y++) {
         for ($x = 0; $x < $w; $x++) {
             if ($frame[$y][$x] == '1') {
                 imagesetpixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
             }
         }
     }
     // saving to file
     $target_image = imagecreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
     imagecopyresized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
     imagedestroy($base_image);
     imagejpeg($target_image, $tempDir . $fileName, $jpegQuality);
     imagedestroy($target_image);
     // displaying
     $qrImg = '<img src="' . Doo::conf()->QR_URL_PATH . $fileName . '" />';
     return $qrImg;
 }
开发者ID:aising,项目名称:ding,代码行数:39,代码来源:HomeController.php

示例7: checkCode

function checkCode($phone)
{
    $len = strlen($phone);
    $phoneWithCode = "+91-";
    if ($len > 10) {
        for ($i = $len - 10; $i < $len; $i++) {
            $phoneWithCode .= $phone[$i];
        }
    } else {
        $phoneWithCode .= $phone;
    }
    return $phoneWithCode;
}
$length = strlen($_POST['userID']);
$link = 'www.makeadiff.in/volunteer/' . $_POST['userID'];
$frame = QRcode::text($link, false, QR_ECLEVEL_L, 4, 0);
$qrcode = get_qrcode($frame);
$idNumber = (string) $_POST['userID'];
$idSixLength = appendZeros($idNumber, $length);
//echo $idSixLength;
ImageTtfText($im, 13, 0, 15, 343, $black, "fonts/BebasNeue-webfont.ttf", $_POST['Post']);
ImageTtfText($im, 15, 0, 48, 382, $black, "fonts/univers.ttf", $phoneNumberAppended);
ImageTtfText($im, 15, 0, 48, 410, $black, "fonts/univers.ttf", $_POST['Email']);
ImageTtfText($im, 13, 0, 637, 324, $madRed, "fonts/BebasNeue-webfont.ttf", "MAD ID : ");
ImageTtfText($im, 13, 0, 682, 324, $madRed, "fonts/BebasNeue-webfont.ttf", $idSixLength);
ImageTtfText($im, 15, 0, 48, 432, $black, "fonts/univers.ttf", $link);
imagecopyresampled($im, $qrcode, 637, 336, 0, 0, 90, 90, 100, 100);
/*
	Parameters
	1. Final Image
	2. Sampled Image
开发者ID:rhit99900,项目名称:madCred,代码行数:31,代码来源:createCard.php

示例8: count

<?php

include '../lib/full/qrlib.php';
include 'config.php';
// custom code rendering with GD2
// WARNING!!! this is 'bad' example:
// - JPEG is bad choice for QR-Codes (loosy, artifacts...)
// - blue is bad choise for FG color (should make hi contrast with BG color)
$codeContents = '12345';
$tempDir = EXAMPLE_TMP_SERVERPATH;
$fileName = '711_test_custom.jpg';
$outerFrame = 4;
$pixelPerPoint = 5;
$jpegQuality = 95;
// generating frame
$frame = QRcode::text($codeContents, false, QR_ECLEVEL_M);
// rendering frame with GD2 (that should be function by real impl.!!!)
$h = count($frame);
$w = strlen($frame[0]);
$imgW = $w + 2 * $outerFrame;
$imgH = $h + 2 * $outerFrame;
$base_image = imagecreate($imgW, $imgH);
$col[0] = imagecolorallocate($base_image, 255, 255, 255);
// BG, white
$col[1] = imagecolorallocate($base_image, 0, 0, 255);
// FG, blue
imagefill($base_image, 0, 0, $col[0]);
for ($y = 0; $y < $h; $y++) {
    for ($x = 0; $x < $w; $x++) {
        if ($frame[$y][$x] == '1') {
            imagesetpixel($base_image, $x + $outerFrame, $y + $outerFrame, $col[1]);
开发者ID:alaingab,项目名称:modx,代码行数:31,代码来源:example_711_custom_gd_output.php


注:本文中的QRcode::text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。