<?php include 'phpqrcode/qrlib.php'; //QRcode::png('some othertext 1234', 'out.png', 'H'); $qr = new QRencode(); $tab = $qr->encode('PHP QR Code :)'); QRspec::debug($tab, true);
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); } }
<?php include '../lib/full/qrlib.php'; // now the fun begins, we use code generating features of library $codeContents = 'Let see what the code structure looks like with a little bit bigger code'; $version = 0; // will be autodetected $eccLevel = QR_ECLEVEL_H; $encodingHint = QR_MODE_8; $caseSensitive = true; $code = new QRcode(); $code->encodeString($codeContents, $version, $eccLevel, $encodingHint, $caseSensitive); QRspec::debug($code->data, false);