Generate QrCodes in PHP | HackerRahul

qrcode banner

Hey, Guys, so in this tutorial, i am going to show you how can you generate QR codes in PHP using Google QrCode Api. So This is the easiest and shortest way to generate QR Codes in PHP.

Demo Download from github

So you can have a look above to the demo.

What is QR Codes?

Basically qrcode is the easiest way to share loads of info by just one pic. and when you scan it using any qrcode scanner all the information is there for you. Its that easy.

So for making the QR code generator you have to call the google qrcode enpoint with a get request.

Google Endpoint –

Required parameters –


chs=250×250 (or any size)

chl=<data> (information you want to create a qr code of.)

So suppose that i want the text hey to make a qrcode of.

Enpoint –×250&chl=hey

And if you wanted to pass a string with spaces, it has to be url encoded so just encode it with phpdefault function urlencode();

and that’s it

there are couple of different thing we can do with qr code like pass url so that when we scna it it’ll open that website directly, and make an sms qrcode so it’ll redirect to the phone’s message app to send the message and the body is pre-written in the body section.

i have included all these examples in the demo given above. and below are the source codes used in this tutorial. please check it out and i’m sure that you’ll be impressed.

Thanks and please subscribe my youtube channel and blog to get more tutorials via email.

Thanks a lot.