我有一个类名'MonthReport.class.php',其结构如下所示:
class MonthReport{
.....
//some member variables
public function pieChart(){
........
//the image data comes from mysql and data belongs to a specified user
$myPicture->Stroke();
}
public function lineChart(){
........
//the image data comes from mysql and data belongs to a specified user
$myPicture->Stroke();
}
public function render html(){
$html.=str1<<<
.....
//some html code
str1;
$html.=<<<str2
<img src="$this->pieChart()" /> //can not work
str2;
}
}
当我在src位置调用pieChart()函数时,它将覆盖我的整个页面并仅显示图像。我该怎么办?我尝试在单独的页面中呈现图像,但是图像需要一些指定的用户数据,例如'userId'。换句话说,当我创建一个对象时,它指定了userId,因此我无法在单独的页面中呈现图像。对不起,我的英语不好!但是我需要你的帮助!谢谢!
您的问题尚不清楚,但是如果您的问题是我假设的问题,那么我曾经遇到过类似的问题(创建的图形只是一个图像,而其余所有页面内容均未显示)。我的解决方案是使用生成一个临时图像,pchart
然后将该文件嵌入html
$myfilename = "temp_image.png"; // temp file name
$myPicture = new pImage(700,500,$myData);
// other image creation code....
$myPicture->Render($myfilename); // generate image "temp_image.png"
$image_html = '<img src="' . $myfilename . '">'; //generate the link
print("$htmlline");
同样,由于您的问题不清楚,因此这里有些猜测。上面的内容对我来说很有效,并使我能够将动态创建的图像嵌入pChart
到我的php
页面中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句