夜间福利网站,免费动漫av,一级做a爰片久久毛片免费陪,夜夜骑首页,黄色毛片视频,插插插操操操,综合av色

PHP學(xué)習(xí):QRCode PHP生成二維碼類庫(kù)

時(shí)間:2025-11-09 18:36:20 php語(yǔ)言 我要投稿

PHP學(xué)習(xí):QRCode PHP生成二維碼類庫(kù)

  在PHP語(yǔ)言中怎么生成二維碼類庫(kù)呢?下面就和小編一起來(lái)看看吧!希望對(duì)大家有用,更多內(nèi)容請(qǐng)關(guān)注應(yīng)屆畢業(yè)生網(wǎng)!

PHP學(xué)習(xí):QRCode PHP生成二維碼類庫(kù)

  使用類庫(kù)的方法

1
2
3
include("Common/QRCode.class.php");
$QRCodenew QRCode();
$categoryList $QRCode->getUrl();

  以下是php生成二維碼完整類庫(kù)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
 
/**
 * 類功能:將指定URL利用google api生成二維碼保存到本地并返回本地訪問(wèn)url
 * author:252588119@qq.com
 * 使用方法見(jiàn):/pic/blog-435.html
 */
class QRCode {
 
    private $path;
    private $size;
 
    public function __construct($path$size) {
        $this->path = empty($path) ? C('webPath') . "/Uploads/QRCode/" $path;
        $this->size = empty($size) ? 80 : $size;
    }
 
    /**
     * 檢測(cè)存儲(chǔ)目錄是否存在,不存在則創(chuàng)建該目錄
     */
    private function makeDir($path) {
        return is_dir($pathor ($this->makeDir(dirname($path)) and @mkdir($path, 0777));
    }
 
    /**
     * 取得二維碼地址
     */
    public function getUrl($url "/pic/blog-435.html") {
        $inPath '/pic/chart?chs=' $this->size . 'x' $this->size . '&cht=qr&chld=L|0&chl=' $url;
        $savePath $_SERVER['DOCUMENT_ROOT'] . $this->path;
        $this->makeDir($savePath);
        $fileName substr(md5("$url"), 8, 16) . "_" $this->size . ".png";
 
        $savePath.=$fileName;
        $outUrl "/pic/code> $_SERVER['HTTP_HOST'] . $this->path . $fileName;
        if (file_exists($savePath) && filesize($savePath) > 0) {
            return $outUrl;
        }
        $in fopen($inPath"rb");
        $out fopen($savePath"wb");
        while ($chunk fread($in, 8192))
            fwrite($out$chunk, 8192);
        fclose($in);
        fclose($out);
        if (filesize($savePath) == 0) {
            $this->getUrl($url);
        else {
            return $outUrl;
        }
    }
 
}
 
?>

【PHP學(xué)習(xí):QRCode PHP生成二維碼類庫(kù)】相關(guān)文章:

PHP學(xué)習(xí):PHP拼音類01-25

PHP學(xué)習(xí):Category類庫(kù)無(wú)限分類03-21

php生成帶logo二維碼方法09-06

PHP生成縮略圖的類的方法08-05

如何生成靜態(tài)頁(yè)面的PHP類10-03

PHP數(shù)據(jù)庫(kù)操作類-ezSQL02-19

PHP封裝數(shù)據(jù)庫(kù)操作類12-05

20個(gè)PHP常用類庫(kù)匯總03-21

php學(xué)習(xí)之php配置03-11

  • 相關(guān)推薦