2

So I have this code:

imagepng($image, 'Result.png');

It will create Result.png file in my server in the same folder

Now I wonder, how to create file like

Result123.png
Result1256.png

Both 123 and 1256 is a value of

$text

Thanks

2 Answers2

2

You can just do:

imagepng($image, 'Result' . $text . '.png');

Howerever, if you are allowing the user to enter the variable $text, this will be vulnerable to cross side scritping (XSS). In that case, use:

$newtext = strip_tags($text);
imagepng($image, 'Result' . $newtext . '.png');
Jan Wilts
  • 82
  • 1
  • 7
1

You need to do is:-

imagepng($image, "Result$text.png");

Note:- I assume that $text is a string variable containg different-different values every-time.

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98