PHP Classes

GD in own function

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  GD in own function  
Subject:GD in own function
Summary:GD functions in my own function not working
Messages:2
Author:ashraful haque
Date:2009-02-26 01:25:44
Update:2009-02-26 01:59:56
 

  1. GD in own function   Reply   Report abuse  
Picture of ashraful haque ashraful haque - 2009-02-26 01:49:27
My code is as below

<?php
// Create a 200 x 200 image
$recwidth=550;
$recheight=300;
$canvas = imagecreate($recwidth, $recheight+30);

// Allocate colors
$white = imagecolorallocate($canvas, 255, 255, 255);
$red = imagecolorallocate($canvas, 255, 0, 0);

function rec($startx, $starty, $endx, $endy){
imagerectangle($canvas, $startx, $starty, $endx, $endy, $black);
}
rec(20,100,500,290);

// Output and free from memory
header('Content-Type: image/jpeg');

imagejpeg($canvas);
imagedestroy($canvas);
?>

but if I make rec function as below

function rec($canvas, $startx, $starty, $endx, $endy, $black){
imagerectangle($canvas, $startx, $starty, $endx, $endy, $black);
}

then It works well. Why?

There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.