To generate a QR code using PHP, you can use the “phpqrcode” library.

First, download and extract the library from its official website (https://github.com/t0k4rt/phpqrcode) or install it using Composer.

Once you have the library files, create a new PHP file and include the main library file:

“`php
require_once(‘phpqrcode/qrlib.php’);
“`

Next, you’ll need to specify the data or URL you want to encode as a QR code. For example, let’s encode a URL:

“`php
$data = ‘https://www.example.com’;
“`

Then, define the file path where you want to save the generated QR code image:

“`php
$filename = ‘qrcode.png’;
“`

Now, you can use the `QRcode::png()` method to generate the QR code image and save it to the specified file path:

“`php
QRcode::png($data, $filename);
“`

Finally, you can output the image HTML to display the QR code image:

“`php
echo ‘QR Code‘;
“`

Here is the complete code:

“`php
‘;
?>
“`

When you run this PHP script, it will generate a QR code image and display it in the browser. The QR code will contain the specified URL.

Note: Make sure the web server has write permissions to the directory where you want to save the QR code image.