zoukankan      html  css  js  c++  java
  • 12 生成二维码

    function qr_code($data, $type = "TXT", $size = '150', $ec = 'L', $margin = '0')
    {
      $types = array("URL" => "http://", "TEL" => "TEL:", "TXT" => "", "EMAIL" => "MAILTO:");
      if (!in_array($type, array("URL", "TEL", "TXT", "EMAIL"))) {
        $type = "TXT";
      }
      if (!preg_match('/^' . $types[$type] . '/', $data)) {
        $data = str_replace("\", "", $types[$type]) . $data;
      }
      $ch = curl_init();
      $data = urlencode($data);
      curl_setopt($ch, CURLOPT_URL, 'http://chart.apis.google.com/chart');
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, 'chs=' . $size . 'x' . $size . '&cht=qr&chld=' . $ec . '|' . $margin . '&chl=' . $data);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_HEADER, false);
      curl_setopt($ch, CURLOPT_TIMEOUT, 30);
      $response = curl_exec($ch);
      curl_close($ch);
      return $response;
    }
    

      

  • 相关阅读:
    歌德巴赫猜想
    Dice Possibility
    ACboy needs your help(简单DP)
    Bag of mice(概率DP)
    合唱队形(LIS)
    地震预测(模拟链表)
    关于KMP算法的感想
    Card Collector
    LOOPS
    Aeroplane chess(简单概率dp)
  • 原文地址:https://www.cnblogs.com/xin-jun/p/6952876.html
Copyright © 2011-2022 走看看