tags:

views:

43

answers:

1

if i have something like this

<?php
$image = imagecreate(300,20);
$background = imagecolorallocate($image,0,0,0);
$foreground = imagecolorallocate($image,255,255,255);


imagestring($image,5,5,1,'sarmenhb, $foreground);
header('Content-type: image/jpeg');
imagejpeg($image);
?>

how does php know the first imagecolorallocate function will be my background witout even specifying it? what if i have multiple functions of that type listed. how will php associate which one ill be using for the background?

thnx

+4  A: 

According to the official PHP manual:

Note: The first call to imagecolorallocate() fills the background color in palette-based images - images created using imagecreate().

http://us3.php.net/manual/en/function.imagecolorallocate.php

Kane Wallmann
ok thanks makes sense, i should've refered to the manual. but hopefully they'll change that in the future. it kind of doesnt make sense to newbees.
Grr Kane. I just finished typing my answer when yours appeared. :)
hobodave
Haha hobodave it would seem you are quite the nemesis :P
Kane Wallmann