Home >Backend Development >PHP Tutorial >Codeigniter框架里面怎么生成qrcode?

Codeigniter框架里面怎么生成qrcode?

WBOY
WBOYOriginal
2016-06-06 20:31:171226browse

请问各位大大,我在Codeigniter的Controller里面调用qrcode,生成的image总是破裂。
但是在非Codeigniter框架中是正常的,不知道哪里错了,请指导谢谢!!
以下是我的代码:

我的controller(q_interface文件已经autoload了):

<code>class Qrcode3 extends CI_Controller {
    public function __construct() {
        parent::__construct();
    }
    public function index() {
        echo $this->q_interface->t("abc");
    }
}
</code>

Q_interface文件:

<code>...//include一些库的
class Q_interface {
    public function t($data) {
        $img = QRcode::png($data);
        $imgData = "data:image/png;base64,".base64_encode($img);
        return $imgData;
    }
}
</code>

回复内容:

请问各位大大,我在Codeigniter的Controller里面调用qrcode,生成的image总是破裂。
但是在非Codeigniter框架中是正常的,不知道哪里错了,请指导谢谢!!
以下是我的代码:

我的controller(q_interface文件已经autoload了):

<code>class Qrcode3 extends CI_Controller {
    public function __construct() {
        parent::__construct();
    }
    public function index() {
        echo $this->q_interface->t("abc");
    }
}
</code>

Q_interface文件:

<code>...//include一些库的
class Q_interface {
    public function t($data) {
        $img = QRcode::png($data);
        $imgData = "data:image/png;base64,".base64_encode($img);
        return $imgData;
    }
}
</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn