Jump to content
xisto Community
Sign in to follow this  
rejected

Php: Write Random Text As Image Having problems, help needed

Recommended Posts

I'm trying to create a script that writes text to an image.

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?
Edited by microscopic^earthling (see edit history)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 B) I didn't know it was used for userdefined variables too :blink: that's new for me :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.