Basically I am in the process of creating a very simple one page .php template that I can easily use for multiple sites. I do not want to have to drag along extra files and such. I am aware of the imagecreate feature and know how to implement it. However, everything I have seen so far involves creating an img.php file and then calling for it on the page you want the image displayed. In my case, I want to eliminate the img.php page and some how just include the code directly on the spot where I want php to create the image.
For example:
<?php
$my_img = imagecreate( 200, 80 );
$background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
$line_colour = imagecolorallocate( $my_img, 128, 255, 0 );
imagestring( $my_img, 4, 30, 25, "thesitewizard.com",
$text_colour );
imagesetthickness ( $my_img, 5 );
imageline( $my_img, 30, 45, 165, 45, $line_colour );
header( "Content-type: image/png" );
imagepng( $my_img );
imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );
?>
I would need to save this code into a file. Let's call it: myimpage.php. Then in order for php to create the image I would need to place this code on the page I want the image to be displayed:
<img src="myimpage.php" alt="Image created by a PHP script" width="200" height="80">
I might as well throw in real image files because this negates what I am trying to achieve. So my question is this: How can I use imagecreate without the need of creating a second php page to call from?
The reason why I need to have this code on the same page is because I want to pass some variables to it.
<h2><a href="./" title="<?php echo $title; ?>"><?php echo $title; ?></a></h2>
THIS IS HERE THE IMAGE GOES (THe IMAGE IS A BASIC BOX THAT DISPLAYS THE CONTENTS OF $IMAGE)
Basically, I want the image to display the contents of $title. So I can't do that if the code is being pulled from another page.