Do Dynamic QR Codes Expire? Dynamic QR codes can expire, but it's entirely up to the business using the QR code when and how. Technically, a QR code doesn't “expire.” Like static QR codes, they're just a matrix of squares that contain information.
Although QR code has many QR solutions you can use, these codes can only be generated in two types: static form or dynamic form.
You cannot convert a static QR Code to a dynamic one as static QR Codes cannot be edited once created.
It's worth adding that, in addition to the QR codes library posted by @abaumg, Google provides a QR Codes API QR Codes APImany thanks to @Toukakoukan for the link update.
To use this , basically:
https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http%3A%2F%2Fwww.google.com%2F&choe=UTF-8
300x300
is the size of the QR image you want to generate,chl
is the url-encoded string you want to change into a QR code, andchoe
is the (optional) encoding.The link, above, gives more detail, but to use it just have the src
of an image point to the manipulated value, like so:
<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http%3A%2F%2Fwww.google.com%2F&choe=UTF-8" title="Link to Google.com" />
Demo:
The easiest way to generate QR codes with PHP is the phpqrcode library.
The phpqrcode library is really fast to configure and the API documentation is easy to understand.
In addition to abaumg's answer I have attached 2 examples in PHP
from http://phpqrcode.sourceforge.net/examples/index.php
1. QR code encoder
first include the library from your local path
include('../qrlib.php');
then to output the image directly as PNG stream do for example:
QRcode::png('your texte here...');
to save the result locally as a PNG image:
$tempDir = EXAMPLE_TMP_SERVERPATH;
$codeContents = 'your message here...';
$fileName = 'qrcode_name.png';
$pngAbsoluteFilePath = $tempDir.$fileName;
$urlRelativeFilePath = EXAMPLE_TMP_URLRELPATH.$fileName;
QRcode::png($codeContents, $pngAbsoluteFilePath);
2. QR code decoder
See also the zxing decoder:
http://zxing.org/w/decode.jspx
Pretty useful to check the output.
3. List of Data format
A list of data format you can use in your QR code according to the data type :
http://
)The endroid/QrCode library is easy to use, well maintained, and can be installed using composer. There is also a bundle to use directly with Symfony.
Installing :
$ composer require endroid/qrcode
Usage :
<?php
use Endroid\QrCode\QrCode;
$qrCode = new QrCode();
$qrCode
->setText('Life is too short to be generating QR codes')
->setSize(300)
->setPadding(10)
->setErrorCorrection('high')
->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))
->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))
->setLabel('Scan the code')
->setLabelFontSize(16)
->setImageType(QrCode::IMAGE_TYPE_PNG)
;
// now we can directly output the qrcode
header('Content-Type: '.$qrCode->getContentType());
$qrCode->render();
// or create a response object
$response = new Response($qrCode->get(), 200, array('Content-Type' => $qrCode->getContentType()));
qrcode-generator on Github. Simplest script and works like charm.
Pros:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With