我总是有这样的错误:
分析错误:语法错误,第10行的/home/user/public_html/nameofsite/application/libraries/Zend/Barcode/Barcode.php中存在意外的T_STRING
下面是我生成条形码的控制器代码:
public function testbarcode()
{
require_once('./application/libraries/Zend/Barcode/Barcode.php');
//adjust the above path to the correct location
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK');
$rendererOptions = array();
Zend_Barcode::factory('code39', 'image', $barcodeOptions, $rendererOptions)->render();
}Barcode.php代码:
命名空间Zend\Barcode;//这是第10行
使用Traversable;使用Zend\Stdlib\ArrayUtils;
/** *生成条形码类*/抽象类条形码{.。。更多代码}
这里的解决方案是什么?我尝试了很多次搜索,但都没有成功,我使用的是codeigniter 2.1.3和zend 2.2.1
发布于 2013-06-27 09:22:52
它应该是
use namespace Zend\Barcode; //this is line 10Parse error: syntax error, unexpected T_STRING说它找到了一个字符串,尽管这个字符串不是预期的。它可能需要一个冒号,即
无论如何,使用Zend\Barcode的要求应该在使用之前。据我所知,您应该需要BarCode的自动加载器,而不是直接使用类。
发布于 2013-07-11 09:43:01
将Zend文件夹复制到codeigniter的system/libraries/并加载lib,如下所示
public function testbarcode()
{
$this->load->library('zend');
$this->zend->load('Zend/Barcode');
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK');
$rendererOptions = array('imageType'=>'png', 'horizontalPosition' => 'center', 'verticalPosition' => 'middle');
Zend_Barcode::factory('code39', 'image', $barcodeOptions, $rendererOptions)->render();
return $imageResource;
}我希望,这是有帮助的
https://stackoverflow.com/questions/17332992
复制相似问题