Welcome Guest ( Log In | Register )




                Web Hosting

 
Reply to this topicNew Topic
Php: Write Random Text As Image, Having problems, help needed!
Rejected
post Jul 16 2005, 06:50 AM
Post #1


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 11
Joined: 10-June 05
Member No.: 6,072


I'm trying to create a script that writes text to an image.
CODE
header("Content-type: image/png");
$_phrases = array(
[tab][/tab]"Test 1",
[tab][/tab]"Test 2",
[tab][/tab]"Test 3",
[tab][/tab]"Test 4",
[tab][/tab]"etc."
);
$_rand_phrase = $_phrases[rand(0,count($_phrases)-1)];
$_image = imagecreatefrompng("gmail.png");
$_user_width = imaagettfbbox(9,0,"tahoma.ttf",$_rand_phrase);
$_x_value = (200-($user_width[2] + 113));
$_color = imagecolorallocate($_image, 165, 164, 164);
imagettftext($_image, 9, 0, $_x_value, 16, $_color, "tahoma.ttf", $_rand_phrase);
imagepng($_image);
imagedestroy($_image);

I can't see what I'm doing wrong.. I know it should work, I'm making a dumb mistake of some sort.

Can anyone help?

This post has been edited by microscopic^earthling: Jul 16 2005, 12:35 PM
Go to the top of the page
 
+Quote Post
szupie
post Jul 17 2005, 02:53 AM
Post #2


S.P.A.M.S.W.A.T.
Group Icon

Group: Members
Posts: 814
Joined: 22-January 05
From: San Antonio, Texas (No, I'm not dumb. I just moved here...)
Member No.: 2,284


You spelled imagettfbbox with an extra a (imaagettfbbox).

And why do you have all your variables start with underscores? You need them only when you want numbers at the beginning of a varible, like $_42lasljwoie. Are you trying to make the variables starting with numbers to look the same as variables starting with letters?
The underscores don't cause a problem, but I'm just curious.
Go to the top of the page
 
+Quote Post
Hercco
post Jul 17 2005, 07:22 PM
Post #3


Super Member
Group Icon

Group: Members
Posts: 595
Joined: 4-September 04
Member No.: 228


QUOTE (Rejected @ Jul 16 2005, 08:50 AM)
I'm making a dumb mistake of some sort.
*


The worst ones to debug.


QUOTE (szupie @ Jul 17 2005, 04:53 AM)
And why do you have all your variables start with underscores?
*


It's a coding convention, I've seen that in few other places too. I don't quite get the point, but that's not the first time...
Go to the top of the page
 
+Quote Post
jvizueta
post Sep 15 2005, 06:25 AM
Post #4


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 22
Joined: 13-September 05
Member No.: 8,434


I've seen that coding convention before but only for private methods, and for predefined global variables like $_GET, $_POST, $_SERVER, $_REQUEST, and so on wink.gif

I didn't know it was used for userdefined variables too blink.gif

that's new for me unsure.gif
Go to the top of the page
 
+Quote Post

Reply to this topicNew Topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No new   38 Bio 8,504 Yesterday, 05:41 PM
Last post by: themetabs
No New Posts   11 sendto 6,941 26th December 2008 - 12:59 PM
Last post by: iG-nwaynge
No New Posts   0 zainboy 95 25th December 2008 - 08:50 PM
Last post by: zainboy
No New Posts   4 CiaraMarie 2,182 23rd December 2008 - 08:24 PM
Last post by: iG-Lucky
No new   26 iciclez 3,304 21st December 2008 - 10:30 AM
Last post by: Quatrux
No New Posts   15 rmdort 4,467 20th December 2008 - 05:38 AM
Last post by: laniczech
No New Posts   14 Mr 85 1,654 17th December 2008 - 03:44 PM
Last post by: ryantommo
No New Posts   3 nighthawk16 2,261 14th December 2008 - 05:51 PM
Last post by: iG-Kudos
No New Posts   2 denverporia19 1,862 11th December 2008 - 10:36 PM
Last post by: iG-Marble
No New Posts   11 ViRuaL 2,360 10th December 2008 - 10:14 PM
Last post by: iG-nick
No New Posts   13 Scionwest 4,808 6th December 2008 - 11:34 PM
Last post by: iG-Levi
No New Posts   8 Mico 456 2nd December 2008 - 07:14 AM
Last post by: The_Fury
No New Posts   3 Sir Joe 2,023 2nd December 2008 - 03:14 AM
Last post by: iG-Ben and Hank
No New Posts   16 jc804 2,335 1st December 2008 - 02:13 PM
Last post by: iG-Sharon
No New Posts 6 miCRoSCoPiC^eaRthLinG 1,986 29th November 2008 - 02:24 PM
Last post by: yordan