PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Dror Golan   PHP QR Code Generator class   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: PHP QR Code Generator class
Generate QR Code images using Google Charts API
Author: By
Last change:
Date: 10 years ago
Size: 1,433 bytes
 

Contents

Class file image Download
<?php

include "QRCodeGenerator.class.php";



/* default values

data - http://google.com (can be either URL or Text)
size (In pixels) - 300
encoding - UTF-8 (Alternative values : Shift_JIS,ISO-8859-1)
error correction level - L
L - [Default] Allows recovery of up to 7% data loss
M - Allows recovery of up to 15% data loss
Q - Allows recovery of up to 25% data loss
H - Allows recovery of up to 30% data loss

margin - 4 rows

*/

/* Ex1 : All default values */
$ex1 = new QRCodeGenerator();
echo
"<img src=".$ex1->generate().">";
/* Ex2 : use different URL and sizing */
$ex2 = new QRCodeGenerator('http://yahoo.com',100);
echo
"<img src=".$ex2->generate().">";
/* Ex3 : Use Text , different sizing and encoding */
$ex3 = new QRCodeGenerator('THIS IS JUST A TEXT',100,'ISO-8859-1');
echo
"<img src=".$ex3->generate().">";
/* Ex4 : default encoding , 'M' level error correction , 1 row for margin */
$ex4 = new QRCodeGenerator('THIS IS JUST A TEXT',100,'','M',1);
echo
"<img src=".$ex4->generate().">";
/* Ex4 : default encoding , level error correction and margin */
$ex5 = new QRCodeGenerator('http://phpclasses.org');
echo
"<img src=".$ex5->generate()."><br>";
/* Ex4 : default encoding . 'H' level error correction , 10 rows for margin with debug*/
$ex6 = new QRCodeGenerator('THIS IS JUST A TEXT',100,'','H',10,true);
echo
"<img src=".$ex6->generate().">";


?>