This site is hosted and sponsored by hyve.com specialists in Cloud Hosting UK and VMware Hosting. If you are interested in our services please call us for chat on 0800 612 2524

Dynamically return an image in PHP#

Create a page called image.php and paste the following code into it:

<?
// create an image with width 100px, height 20px
$image = imagecreate(100, 20);
// create a red colour for the background
// as it is the first call to imagecolorallocate(), this fills the background automatically
$red_background = imagecolorallocate($image, 255, 0, 0);
// create a black colour for writing on the image
$black = imagecolorallocate($image, 0, 0, 0);
// write the string "Hyve test" on the image
// the top left of the text is at the position (10, 2)
imagestring($image, 4, 10, 2,' hyve test', $black);
// output the image
// tell the browser what we.re sending it
Header('Content-type: image/png');
// output the image as a png
imagepng($image);
// tidy up
imagedestroy($image);
?>

Create a page called image.html and paste the following code into it:


<img src="http://www.domain.com/image.php"/>

Surf to the html page and you will see that the image appears.

Back to PHP

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-1) was last changed on 24-Apr-2007 15:00 by UnknownAuthor
G’day (anonymous guest) My Prefs
  • View Page Source
  • This clear IPSec security association,
    clear ipsec sa peer X.X.X.X
    

All Pages

Page views: 5041

Private Tomcat

Linux

MySQL

Email

SQL Server

ASP

JSP

C#

Web Mail

Windows Plesk

Linux Plesk

PHP

Gaming

ASP.NET

Persits ASPUpload

Wiki Help

Referring Pages:
...nobody

JSPWiki v2.8.1