phpgd2

Display multiple variables in an image


I'm trying to use multiple variables as the string inside an image generated in PHP, but I keep getting the following error:

Parse error: syntax error, unexpected '' - '' (T_CONSTANT_ENCAPSED_STRING) in C:\xampp\htdocs\Projects\scrobbl.in\image.php on line 36

What am I doing wrong?

Here's my code:

<?php
$img_number = imagecreate(275,25);
$backcolor = imagecolorallocate($img_number,102,102,153);
$textcolor = imagecolorallocate($img_number,255,255,255);
imagefill($img_number,0,0,$backcolor);
Imagestring($img_number,10,5,5,$currenttrack' - '$artist,$textcolor);
header("Content-type: image/jpeg");
imagejpeg($img_number);
?>

Solution

  • This should work for you:

    Imagestring($img_number,10,5,5,"$currenttrack" . " - " . "$artist",$textcolor);