嗨有以下功能
function renderBusinessCard($details){
//Getting the template for the business card
$filename = Templates::model()->getTemplateFileName($details['BusinessCards']['dp_id']);
header("Content-type: image/jpeg");
$image = $_SERVER['DOCUMENT_ROOT'].'resources/templates/'.$filename;
// header("Content-Type: image/jpeg");
//Getting the width and height of the image
list($width,$height) = getimagesize($image);
//echo $width;die;
//Creating a copy of a loaded image
$create = imagecreatefromjpeg($image);
//Creating a blank template to work from
$template = imagecreatetruecolor($width,$height);
imagecopyresized($template, $create, 0, 0, 0, 0, $width, $height, $width, $height);
imagejpeg($template, null, 100);
}
<img src="<?PHP renderBusinessCard($details); ?>"
但不知何故,它总是将乱码代码渲染到屏幕而不是我想要的结果.这是可能吗?如果不使用单独的文件,我希望它保留在一个函数或方法中.
解决方法:
您需要在单独的资源中呈现图像.没有好的方法在HTML文档中添加图像数据. (任何人都在考虑推荐数据:URI:这是一个糟糕的主意.)
<img src="renderBusinessCard.PHP?param1=1¶m2=2">