是的我知道我正在使用CodeIgniter Lol
Zend条形码阅读器很好但我想将渲染的条形码保存在变量中,所以只有当我在视图中调用变量时(例如echo $ myvar)才会显示条形码
我的代码
public function find_rma_authorization() {
// get the posted term
$rmaNumber = $this->input->post('con_rma_number');
// use the model
$data['results'] = $this->search_model->get_rma_authorization_data($rmaNumber);
$data['barcode'] = $this->set_barcode($rmaNumber);
$this->load->view('templates/header');
$this->load->view('posts/rma_request_window', $data);
$this->load->view('templates/footer');
}
private function set_barcode($code)
{
//load library
$this->load->library('zend');
//load in folder Zend
$this->zend->load('Zend/Barcode');
//generate barcode
Zend_Barcode::render('code128', 'image', array('text'=>$code), array());
}
答案 0 :(得分:2)
您需要从函数中返回条形码:
return Zend_Barcode::render('code128', 'image', array('text'=>$code), array());
<强>更新强>
抱歉,我误解了你的问题。你可以试试这个:
控制器
//load library
$this->load->library('zend');
//load in folder Zend
$this->zend->load('Zend/Barcode');
//create barcode object
$barcode = Zend_Barcode::factory('code128', 'image', $barcodeOptions, $rendererOptions);
$data['barcode'] = $barcode;
$this->load->view('posts/rma_request_window', $data);
查看
// render
$barcode->render();
答案 1 :(得分:0)
尝试在视图上使用此代码
<img src="<?php echo site_url(); ?>/controller_name/set_barcode/<?php echo $rmaNumber; ?>">