如何使用php生成多个文本
如何使用如何使用php生成多个文本,php,text,image-processing,Php,Text,Image Processing,如何使用imagecreatetruecolor()方法生成多个文本?我有以下代码,但这会显示第一种字体或第二种字体,而不是两者都显示: <?php // Set the content-type header('Content-type: image/png'); // The text to draw $text = 'Hello Farooqi'; $x = 0; $y = 0; $w = 50; $h = 50;
imagecreatetruecolor()
方法生成多个文本?我有以下代码,但这会显示第一种字体或第二种字体,而不是两者都显示:
<?php
// Set the content-type
header('Content-type: image/png');
// The text to draw
$text = 'Hello Farooqi';
$x = 0;
$y = 0;
$w = 50;
$h = 50;
$s = 13;
// Create the image
$im = imagecreatetruecolor($w , $s);
imagesavealpha($im, true);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im,0,0,0);
$text_color = imagecolorallocate($im, 200,200, 91);
$blue = imagecolorallocate($im,0,0,180);
$alpha = imagecolorallocatealpha($im, 0, 0, 0, 127);
//imagefilledrectangle($im, 0, 0, 150, 25, $black);
imagefill($im, 0, 0, $alpha);
// Replace path by your own font path
$font = 'Calibri Bold.ttf';
// Add the text
$dimensions = imagettftext($im, $s, 0, $x, $y, $black, $font, $text);
$textWidth = ($dimensions[2]);
$imm = imagecreatetruecolor($w , $s);
imagesavealpha($imm, true);
$bluem = imagecolorallocate($imm,50,50,50);
$alpham = imagecolorallocatealpha($imm, 0, 0, 0, 127);
imagefill($imm, 0, 0, $alpham);
imagettftext($imm, $s, 0, $x+3, $y+3, $bluem, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagepng($imm);
imagedestroy($im);
imagedestroy($imm);
?>
在上面的最后4行中,只有一行出现,这是第一行。我怎么能同时拥有这两条线
请帮忙。提前感谢。图像PNG($im);将被调用并输出到HTML代码中,当标题设置为图像时,它将显示此图像。不管你的图像PNG($inm)之后会出现什么
更好的方法是创建两个不同的PHP文件。完成脚本并以imagepng($im)结尾的脚本;另一个以imagepng($inm)结尾
然后在主PHP(header=text/html)文件中,您只需在图像源中提到以下两个文件:
<img src="functions/first_image.php" />
<img src="functions/second_image.php" />
非常感谢。。实际上,当我在这里粘贴代码时。。然后开始编辑我的代码。。我找到了解决办法。。我把这篇课文写成了一份表格$text=$_GET['text'];并加载了参数。。我不知道这个问题。。但是谢谢你现在我明白了。。它是一个一次只返回一个输出的函数:)