07-11-2004, 01:51 AM
[syntax="PHP"]<?php
header("Content-type: image/png");
function left ($str, $howManyCharsFromLeft)
{
return substr ($str, 0, $howManyCharsFromLeft);
}
function right ($str, $howManyCharsFromRight)
{
$strLen = strlen ($str);
return substr ($str, $strLen - $howManyCharsFromRight, $strLen);
}
function LoadPNG($imgname)
{
global $im;
$im = @imagecreatefrompng($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate(150, 30); /* Create a blank image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
function adjusttext(text$,y)
{
if(strlen(text$) > 10) {
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 255,0,0);
imagestring($im, 2,20,20, left($text, 10), $text_color);
y = 30;
$text = right($text,strlen - 10);
}
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 255,0,0);
imagestring($im, 2,20,y, $text, $text_color);
}
$text = "Hello Meow";
LoadPNG("WT.png");
adjusttext ($text, 20)
imagepng($im);
imagedestroy($im);
?> [/syntax]
i get
Parse error: parse error, unexpected T_STRING, expecting ')' in /home/whtiger/public_html/pic.php on line 31
Whats wrong? :???:
header("Content-type: image/png");
function left ($str, $howManyCharsFromLeft)
{
return substr ($str, 0, $howManyCharsFromLeft);
}
function right ($str, $howManyCharsFromRight)
{
$strLen = strlen ($str);
return substr ($str, $strLen - $howManyCharsFromRight, $strLen);
}
function LoadPNG($imgname)
{
global $im;
$im = @imagecreatefrompng($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate(150, 30); /* Create a blank image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
function adjusttext(text$,y)
{
if(strlen(text$) > 10) {
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 255,0,0);
imagestring($im, 2,20,20, left($text, 10), $text_color);
y = 30;
$text = right($text,strlen - 10);
}
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 255,0,0);
imagestring($im, 2,20,y, $text, $text_color);
}
$text = "Hello Meow";
LoadPNG("WT.png");
adjusttext ($text, 20)
imagepng($im);
imagedestroy($im);
?> [/syntax]
i get
Parse error: parse error, unexpected T_STRING, expecting ')' in /home/whtiger/public_html/pic.php on line 31
Whats wrong? :???: