【发布时间】:2021-10-11 08:44:25
【问题描述】:
我正在尝试创建包含员工图片的名片二维码
if (file_exists($employeeBCpicture)) {
$imagedata = file_get_contents($employeeBCpicture);
$photo64 = base64_encode($imagedata);
}else {//echo 'No<br>';
}
// QR bind_textdomain_codeset
//Include the necessary library for Ubuntu
include_once('/usr/share/phpqrcode/qrlib.php');
//Set the data for QR
$text =
'BEGIN:VCARD'. "\n".
'VERSION:2.1.'. "\n".'
N:'.ucwords($rowe['lname']).';'.ucwords($rowe['fname']).';;;'. "\n".'
FN:'. $fullname. "\n".'
TEL;WORK:+'.$phoneline. "\n".'
TEL;CELL:+'.$mobile. "\n".'
EMAIL;WORK:'.$email. "\n".'
URL;WORK:'.$website. "\n".'
ORG:'.ucwords($rowc['companyname']). "\n".'
TITLE:'.$title. "\n".'
ADR;WORK:;;'.$address.';;'. "\n";
if ($photo64 != ''){
$text = $text.'PHOTO;TYPE=PNG;ENCODING=BASE64:
'.$photo64.' '. "\n".' '
. "\n".' '
. "\n".' ' ;
}
$text = $text.'
END:VCARD';
//Set the filename with unique id
//echo $text.'<br>';
$rfilename = '../../../signatures/'.uniqid().".png";
//Set the error correction Level('L')
$e_correction = 'L';
//Set pixel size
$pixel_size = 2;
//Set the frame size
$frame_size = 2;
//Generates QR image
QRcode::png($text, $rfilename, $e_correction, $pixel_size, $frame_size);
我的问题是 \n 不起作用,需要添加新行 评论以下部分时,二维码有效(删除照片部分) 照片部分需要三个 \n 3 新行才能工作 我还需要添加新行来格式化名片
if ($photo64 != ''){
$text = $text.'PHOTO;TYPE=PNG;ENCODING=BASE64:
'.$photo64.' '. "\n".' '
. "\n".' '
. "\n".' ' ;
}
我的问题是 php 变量 $text 给了我内联输出,我需要在使用 QRcode 函数之前分隔行
提前感谢您的帮助
【问题讨论】:
标签: php