A QR code is a special 2-dimensional code that is used to transmit short information, e.g. to a mobile phone.
QR codes can be easily generated by simply inserting an image on Google's servers.
For example:
<img src="https://chart.apis.google.com/chart?cht=qr&chs=100x100&choe=UTF-8&chld=H%7C0&chl=https://php.baraja.cz" alt="QR code">
We can set 3 parameters:
px (vertical and horizontal)UTF-8)TIP: If there is a mobile version of the site, link to that instead.
In most cases, your QR code will be processed by your mobile phone.
It is very easy to write your own function for embedding:
function getQrCode(string $url, int $size = 128, string $charset = 'UTF-8'): string{$size = $size < 16 ? 16 : ($size > 2048 ? 2048 : $size);return '<img src="https://chart.apis.google.com/chart?cht=qr&chs=. $size . 'x' . $size. '&choe=' . urlencode($charset). '&chld=H%7C0&chl=' . urlencode($url). '">';}echo getQrCode('https://php.baraja.cz');
Autor článku pracuje jako seniorní vývojář a software architekt v Praze. Navrhuje a spravuje velké webové aplikace, které znáte a používáte. Od roku 2009 nabral bohaté zkušenosti, které tímto webem předává dál.
Rád vám pomůžu:
Nejlepsi tipy a triky o PHP do Vaseho e-mailu. Clanky a novinky nejen ze sveta PHP a programovani.