Change language

Dynamically generating QR code using PHP

QRcode::png ($text, $file, $ecc, $pixel_Size, $frame_Size); 
Parameters:This function takes five parameters as above and described below:
  • $text:this parameter will return a message that should be in QR code. This is a required parameter.
  • $file:specifies a location to save the generated QR.
  • $ecc:This parameter specifies the ability to fix QR errors. Has 4 levels L, M, Q and H.
  • $pixel_Size:specifies the QR pixel size.
  • $frame_Size:indicates the size of Qr. This is from level 1-10.
Example 1:PHP program to generate QR code.  
// Include qrlib file include ’phpqrcode / qrlib.php’ ;  
// $text variable contains data for QR $text = "GEEKS FOR GEEKS" ;  
// Generate QR code using png()
// When this function only has
// text parameter is it directly
// outputs QR to browser QRcode::png ( $text ); ?>
Output: Note.This output is generated directly in the browser. This code will not work in the online IDE as it cannot contain the phpqrcode module.Example 2:PHP program to generate QR code and create file.
// Include qrlib file include ’phpqrcode / qrlib.php’ ; $text = "GEEKS FOR GEEKS " ;  
// $path variable stores where
// save the image and $file creates the directory name
// QR code file using ’ uniqid ’
// uniqid creates a unique identifier based on microtime $path = ’images /’ ; $file = $path . uniqid(). ". png" ;  
// $ecc stores bug fixes (’ L ’) $ecc = ’L’ ; $pixel_Size = 10; $frame_Size = 10;  
// Generates a QR code and saves it in the specified directory QRcode::png ( $text , $file , $ecc , $pixel_Size , $frame_size );  
// Display the saved QR code from the directory echo "< center > . $file . "’ > < / center > " ; ?> Output: Note . The output of both examples is different. In the first example, the output will be displayed with a default frame and pixel size, which is generated directly in the browser, while the output of the second example is a "png" file with a pixel and frame size of 10 in the directory.
SO 1 data error