PHP QrCode Liblary 2.0

- Main Page
- Related Pages
- Modules
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
QRcode Class Reference
Standard API Core

Main class to create QR-code. More...

## Public Member Functions
| encodeMask (QRinput $input, $mask)
| Encode mask Main function responsible for creating code. More...
| encodeInput (QRinput $input)
| Encode input with mask detection. More...
| encodeString8bit ($string, $version, $level)
| Encode string, forcing 8-bit encoding. More...
| encodeString ($string, $version, $level, $hint, $casesensitive)
| Encode string, using optimal encodings. More...

## Static Public Member Functions
static | png ($text, $outfile=false, $level=QR_ECLEVEL_L, $size=3, $margin=4, $saveandprint=false)
| Creates PNG image containing QR-Code. More...
static | text ($text, $outfile=false, $level=QR_ECLEVEL_L, $size=3, $margin=4)
| Creates text (1's & 0's) containing QR-Code. More...
static | raw ($text, $outfile=false, $level=QR_ECLEVEL_L, $size=3, $margin=4)
| Creates Raw Array containing QR-Code. More...
static | canvas ($text, $elemId=false, $level=QR_ECLEVEL_L, $width=false, $size=false, $margin=4, $autoInclude=false)
| Creates Html+JS code to draw QR-Code with HTML5 Canvas. More...
static | svg ($text, $elemId=false, $outFile=false, $level=QR_ECLEVEL_L, $width=false, $size=false, $margin=4, $compress=false)
| Creates SVG with QR-Code. More...

## Public Attributes
| $version
| Integer QR code version. Size of QRcode is defined as version. Version is from 1 to 40. Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. So version 40 is 177*177 matrix.
| $width
| Integer Width of code table. Because code is square shaped - same as height.
| $data
| Array Ready, masked code data.

## Static Public Attributes
static | $jscanvasincluded = false
| Canvas JS include flag. More...

## Detailed Description

Main class to create QR-code.

QR Code symbol is a 2D barcode that can be scanned by handy terminals such as a mobile phone with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and has high robustness. This class supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004.

Currently the following features are not supported: ECI and FNC1 mode, Micro QR Code, QR Code model 1, Structured mode.

Class for generating QR-code images, SVG and HTML5 Canvas

Author
  Dominik Dzienia

Copyright
  2010-2013 Dominik Dzienia and others http://www.gnu.org/copyleft/lesser.html LGPL

## Member Function Documentation

static QRcode::canvas | ( |  | $text,
|  |  | $elemId = `false`,
|  |  | $level = `QR_ECLEVEL_L`,
|  |  | $width = `false`,
|  |  | $size = `false`,
|  |  | $margin = `4`,
|  |  | $autoInclude = `false`
| ) |  |
| static

Creates Html+JS code to draw QR-Code with HTML5 Canvas.

Simple helper function to create QR-Code array with one static call.

Parameters

  String | $text | text string to encode
  String | $elemId | (optional) target Canvas tag id attribute, if false Canvas tag with auto id will be created
  Integer | $level | (optional) error correction level QR_ECLEVEL_L, QR_ECLEVEL_M, QR_ECLEVEL_Q or QR_ECLEVEL_H
  Integer | $width | (optional) CANVAS element width (sam as height)
  Integer | $size | (optional) pixel size, multiplier for each 'virtual' pixel
  Integer | $margin | (optional) code margin (silent zone) in 'virtual' pixels
  Boolean | $autoInclude | (optional) if true, required qrcanvas.js lib will be included (only once)

Returns
  String containing JavaScript creating the code, Canvas element (when $elemId is false) and script tag with required lib (when $autoInclude is true and not yet included)

QRcode::encodeInput | ( | QRinput | $input) |  |

Encode input with mask detection.

Shorthand for encodeMask, without specifing particular, static mask number.

Parameters

  QRinput | $input | data object to be encoded

Returns

QRcode::encodeMask | ( | QRinput | $input,
|  |  | $mask
| ) |  |

Encode mask Main function responsible for creating code.

We get empty frame, then fill it with data from input, then select best mask and apply it. If $mask argument is greater than -1 we assume that user want's that specific mask number (ranging form 0-7) to be used. Otherwise (when $mask is -1) mask is detected using algorithm depending of global configuration,

Parameters

  QRinput | $input | data object
  Integer | $mask | sugested masking mode

Returns
  QRcode $this (current instance)

QRcode::encodeString | ( |  | $string,
|  |  | $version,
|  |  | $level,
|  |  | $hint,
|  |  | $casesensitive
| ) |  |

Encode string, using optimal encodings.

Encode string dynamically adjusting encoding for subsections of string to minimize resulting code size. For complex string it will split string into subsections: Numerical, Alphanumerical or 8-bit.

Parameters

  String | $string | input string
  Integer | $version | code version (size of code area)
  String | $level | ECC level (see: Global Constants -> Levels of Error Correction)
  Integer | $hint | QR_MODE_8 or QR_MODE_KANJI, Because Kanji encoding is kind of 8 bit encoding we need to hint encoder to use Kanji mode explicite. (otherwise it may try to encode it as plain 8 bit stream)
  Boolean | $casesensitive | hint if given string is case-sensitive, because if not - encoder may use optimal QR_MODE_AN instead of QR_MODE_8

Returns
  QRcode $this (current instance)

QRcode::encodeString8bit | ( |  | $string,
|  |  | $version,
|  |  | $level
| ) |  |

Encode string, forcing 8-bit encoding.

Parameters

  String | $string | input string
  Integer | $version | code version (size of code area)
  Integer | $level | ECC level (see: Global Constants -> Levels of Error Correction)

Returns
  QRcode $this (current instance)

static QRcode::png | ( |  | $text,
|  |  | $outfile = `false`,
|  |  | $level = `QR_ECLEVEL_L`,
|  |  | $size = `3`,
|  |  | $margin = `4`,
|  |  | $saveandprint = `false`
| ) |  |
| static

Creates PNG image containing QR-Code.

Simple helper function to create QR-Code Png image with one static call.

Parameters

  String | $text | text string to encode
  String | $outfile | (optional) output file name, if false outputs to browser with required headers
  Integer | $level | (optional) error correction level QR_ECLEVEL_L, QR_ECLEVEL_M, QR_ECLEVEL_Q or QR_ECLEVEL_H
  Integer | $size | (optional) pixel size, multiplier for each 'virtual' pixel
  Integer | $margin | (optional) code margin (silent zone) in 'virtual' pixels
  Boolean | $saveandprint | (optional) if true code is outputed to browser and saved to file, otherwise only saved to file. It is effective only if $outfile is specified.

static QRcode::raw | ( |  | $text,
|  |  | $outfile = `false`,
|  |  | $level = `QR_ECLEVEL_L`,
|  |  | $size = `3`,
|  |  | $margin = `4`
| ) |  |
| static

Creates Raw Array containing QR-Code.

Simple helper function to create QR-Code array with one static call.

Parameters

  String | $text | text string to encode
  Boolean | $outfile | (optional) not used, shuold be false
  Integer | $level | (optional) error correction level QR_ECLEVEL_L, QR_ECLEVEL_M, QR_ECLEVEL_Q or QR_ECLEVEL_H
  Integer | $size | (optional) pixel size, multiplier for each 'virtual' pixel
  Integer | $margin | (optional) code margin (silent zone) in 'virtual' pixels

Returns
  Array containing Raw QR code

static QRcode::svg | ( |  | $text,
|  |  | $elemId = `false`,
|  |  | $outFile = `false`,
|  |  | $level = `QR_ECLEVEL_L`,
|  |  | $width = `false`,
|  |  | $size = `false`,
|  |  | $margin = `4`,
|  |  | $compress = `false`
| ) |  |
| static

Creates SVG with QR-Code.

Simple helper function to create QR-Code SVG with one static call.

Parameters

  String | $text | text string to encode
  Boolean | $elemId | (optional) target SVG tag id attribute, if false SVG tag with auto id will be created
  String | $outfile | (optional) output file name, when false file is not saved
  Integer | $level | (optional) error correction level QR_ECLEVEL_L, QR_ECLEVEL_M, QR_ECLEVEL_Q or QR_ECLEVEL_H
  Integer | $width | (optional) SVG element width (sam as height)
  Integer | $size | (optional) pixel size, multiplier for each 'virtual' pixel
  Integer | $margin | (optional) code margin (silent zone) in 'virtual' pixels
  Boolean | $compress | (optional) if true, compressed SVGZ (instead plaintext SVG) is saved to file

Returns
  String containing SVG tag

static QRcode::text | ( |  | $text,
|  |  | $outfile = `false`,
|  |  | $level = `QR_ECLEVEL_L`,
|  |  | $size = `3`,
|  |  | $margin = `4`
| ) |  |
| static

Creates text (1's & 0's) containing QR-Code.

Simple helper function to create QR-Code text with one static call.

Parameters

  String | $text | text string to encode
  String | $outfile | (optional) output file name, when false file is not saved
  Integer | $level | (optional) error correction level QR_ECLEVEL_L, QR_ECLEVEL_M, QR_ECLEVEL_Q or QR_ECLEVEL_H
  Integer | $size | (optional) pixel size, multiplier for each 'virtual' pixel
  Integer | $margin | (optional) code margin (silent zone) in 'virtual' pixels

Returns
  Array containing line of code with 1 and 0 for every code line

## Member Data Documentation

QRcode::$jscanvasincluded = false
| static

Canvas JS include flag.

If canvas js support library was included, we remember it static in QRcode. (because file should be included only once)

The documentation for this class was generated from the following file:

- lib/full/qrencode.php