Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP wordwrap picture thingy >_<
#1
[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? :???:
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#2
NEVERMIND I got it. I dont know what was wring but I redid the bad part.
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#3
The highlighter would have told you: text$ should be $text Wink
Reply
#4
Quote:The highlighter would have told you: text$ should be $text Wink

:o cant beleive i didn't notice that
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)