本文整理汇总了PHP中QRtools::buildCache方法的典型用法代码示例。如果您正苦于以下问题:PHP QRtools::buildCache方法的具体用法?PHP QRtools::buildCache怎么用?PHP QRtools::buildCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRtools
的用法示例。
在下文中一共展示了QRtools::buildCache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}