我收到错误消息:Unexpected character in input: '\' (ASCII=92) state=1
当使用 KENDO UI 执行控制器以生成图形并包含如下语法时:$valueAxis = new \Kendo\Dataviz\UI\ChartValueAxisItem();
我发现它是 php 版本错误,低于 5.3 的版本不支持命名空间,但我使用 Zend 框架 1.12 运行 PHP 5.4 .3 & 我仍然有这个错误。
控制器:
class StatsController extends Oft_Controller_Action
{
function init ()
{
require_once 'library/Kendo/Autoload.php';
}
public function indexAction(){
$india = new \Kendo\Dataviz\UI\ChartSeriesItem();
$india->name('India')
->data(array(3.907, 7.943, 7.848, 9.284, 9.263, 9.801, 3.890, 8.238, 9.552, 6.855));
$valueAxis = new \Kendo\Dataviz\UI\ChartValueAxisItem();
$valueAxis->labels(array('format' => '{0}%'))
->line(array('visible' => false))
->axisCrossingValue(-10);
$categoryAxis = new \Kendo\Dataviz\UI\ChartCategoryAxisItem();
$categoryAxis->categories(array(2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011))
->majorGridLines(array('visible' => false));
$tooltip = new \Kendo\Dataviz\UI\ChartTooltip();
$tooltip->visible(true)
->format('{0}%')
->template('#= series.name #: #= value #');
$chart = new \Kendo\Dataviz\UI\Chart('chart');
$chart->title(array('text' => 'Gross domestic product growth /GDP annual %/'))
->legend(array('position' => 'bottom'))
->addSeriesItem($india)
->addValueAxisItem($valueAxis)
->addCategoryAxisItem($categoryAxis)
->tooltip($tooltip)
->seriesDefaults(array('type' => 'line'));
echo $chart->render();
}
}
谢谢您的帮助