How to generate qrcode in the Codeigniter framework?

Source: Internet
Author: User
Tags autoload codeigniter
I call qrcode in the Controller of Codeigniter. The generated image is always broken. But it is normal in a non-Codeigniter framework. I don't know where the error is. Thank you !! The following is my code: My controller (the q_interface file is already a... can you tell me that I call qrcode in the Controller of Codeigniter, And the generated image is always broken.
But it is normal in a non-Codeigniter framework. I don't know where the error is. Thank you !!
The following is my code:

My controller (the q_interface file has been autoload ):

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

Q_interface file:

... // Include the class Q_interface {public function t ($ data) {$ img = QRcode: png ($ data); $ imgData = "data: image/png; base64 ,". base64_encode ($ img); return $ imgData ;}}

Reply content:

I call qrcode in the Controller of Codeigniter. The generated image is always broken.
But it is normal in a non-Codeigniter framework. I don't know where the error is. Thank you !!
The following is my code:

My controller (the q_interface file has been autoload ):

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

Q_interface file:

... // Include the class Q_interface {public function t ($ data) {$ img = QRcode: png ($ data); $ imgData = "data: image/png; base64 ,". base64_encode ($ img); return $ imgData ;}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.