我按照 wiki 文章 (http://codeigniter.com/wiki/gchart/revision/5312/) 在我的 CI 2.0 中练习 google chart。但它不起作用。
控制器文件:ci\application\helpers\mytest.php
$this->load->helper( 'gchart' );
$this->load->view('my_test');
查看文件:ci\application\helpers\my_test.php
$encoded_data = extendedencode(array(0, 1, 2, 3, 4, 5, 6) &maxvalue;);
echo <<< EOS
<img src="
http://chart.apis.google.com/chart?
cht=lc
&chs=250x250
&chd;:e{$encoded}
"
alt="line graph of some example data" />
EOS;
帮助文件:ci\application\helpers\gchart_helper.php
// I do copied all the source code from the wiki url link above.
当我尝试按 CI 绘制图表时。它显示错误, 解析错误:语法错误,意外';' 在第 54 行的 C:\xampp\htdocs\demo\ci\application\views\my_test.php
我的操作有什么问题吗?我比较了 gchart_helper.php 中的 extendedencode()
function extendedencode($data, &$maxvalue='notspecified')
和来自 my_test.php 的扩展编码()
$encoded_data = extendedencode(array(0, 1, 2, 3, 4, 5, 6) &maxvalue;);
然后我在 my_test.php 视图文件中更新了 extendedencode() 行,
$encoded_data = extendedencode(array(0, 1, 2, 3, 4, 5, 6), &maxvalue);
再试一次,但仍然在下面出现此错误。
解析错误:语法错误,意外 ')',在第 54 行的 C:\xampp\htdocs\demo\ci\application\views\my_test.php 中期望 T_PAAMAYIM_NEKUDOTAYIM
非常感谢任何帮助或评论。
[更新]
When I use the formated below,
$encoded_data = extendedencode(array(0, 1, 2, 3, 4, 5, 6) &maxvalue);
showed another four error message.
Events List
A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant maxvalue - assumed 'maxvalue'
Filename: views/my_test.php
Line Number: 54
A PHP Error was encountered
Severity: Warning
Message: max() [function.max]: When only one parameter is given, it must be an array
Filename: helpers/gchart_helper.php
Line Number: 49
A PHP Error was encountered
Severity: Warning
Message: Division by zero
Filename: helpers/gchart_helper.php
Line Number: 55
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: encoded
Filename: views/my_test.php
Line Number: 61
[针对弗兰克的建议进行了更新]
下面仍然出现两个错误,
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 64
Filename: helpers/gchart_helper.php
Line Number: 65 // code line: $ret .= $grid[$x].$grid[$y];
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: encoded
Filename: views/my_test.php
Line Number: 61 // code line: &chd;:e{$encoded}