imagestring example

This is an example of using the imagestring function in PHP

Header(“Content-type: image/jpeg”);
//width and height of image
$width = 468;
$heigth = 60;
$image = ImageCreate($width,$heigth);
//black background
$black = ImageColorAllocate($image,0,0,0);
//for the text
$white = ImageColorAllocate($image,255,255,255);
parameters for imagestring:
1: resource image, in this case $image
2: font, 1 to 5 are built in fonts in this case 3
3: int x, x co-ordinate in this case 10
4: int y, y co-ordinate in this case 20
5: string s, the string to be displayed in this case “hello world”
6: int col. the color to display the text in, in this case the variable $white
imagestring($image,3,10,20,”Hello World”,$white);
//output jpeg
//clean up


Please enter your comment!
Please enter your name here