作者 开飞机的舒克

二维码生成

@@ -69,6 +69,11 @@ class Demo extends Api @@ -69,6 +69,11 @@ class Demo extends Api
69 */ 69 */
70 public function test3() 70 public function test3()
71 { 71 {
  72 + $unique = "张三";
  73 + $generate = Generate::qr();
  74 + $file_path = $generate->create($unique,true,true);
  75 + $file_path = substr($file_path,strripos($file_path,"public")+6);
  76 + return $file_path;
72 } 77 }
73 78
74 } 79 }
@@ -54,9 +54,9 @@ class Qr extends Gateway{ @@ -54,9 +54,9 @@ class Qr extends Gateway{
54 } 54 }
55 55
56 if(is_int($data)){ 56 if(is_int($data)){
57 - $file_name = 'qr'.$data.'.png';  
58 - }else{  
59 $file_name = 'qr'.date('YmdHis').rand(1111,9999).'.png'; 57 $file_name = 'qr'.date('YmdHis').rand(1111,9999).'.png';
  58 + }else{
  59 + $file_name = $data.'.png';
60 } 60 }
61 $filename = $filePath.$file_name; 61 $filename = $filePath.$file_name;
62 QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2); 62 QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);