PHP code example of sujanshresthanet / php-qrcode-generator

1. Go to this page and download the library: Download sujanshresthanet/php-qrcode-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sujanshresthanet / php-qrcode-generator example snippets




$f = "visit.php";
if(!file_exists($f)){
	touch($f);
	$handle =  fopen($f, "w" ) ;
	fwrite($handle,0) ;
	fclose ($handle);
}
 $username;
}
$email = '';
$subject = '';
$body = '';
if(isset($_POST['submit']) ) {
	// set error correction level L
	$err_correction = 'L';
	$pixel_size = 8;
	$frame_size = 8;
	$tempDir = 'images/';
	$errorMessage = '';
	$folderPermission = substr(sprintf('%o', fileperms($tempDir)), -4);
	if($folderPermission != '777' && $folderPermission != '0777') {
		$errorMessage = 'You do not have permissions to generate a file to a directory - '.$tempDir.'. Please change the folder permission to 777.';
	} else {
		$email = $_POST['mail'];
		$subject =  $_POST['subject'];
		$filename = getUsernameFromEmail($email);
		$body =  $_POST['msg'];
		$codeContents = 'mailto:'.$email.'?subject='.urlencode($subject).'&body='.urlencode($body);
		QRcode::png($codeContents, $tempDir.''.$filename.'.png', $err_correction, $pixel_size, $frame_size);
	}
}

composer