|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-07-06 17:34 UTC] robotech at mixmail dot com
Description:
------------
I'm using GD to generate a dinamic image showing a chart.
It sees that there's and error when I try to use the keyword "include".
I also try to use an empty file using the keyword "include" and the result it's the same.
Reproduce code:
---------------
/*************/
/* chart.php */
/*************/
Header ("Contect-type: image/jpeg");
include ("function.phtml"); //only a group of functions. They all work.
$imgW = 500; $imgH = 312;
$img = ImageCreate($imgW,$imgH);
$black = ImageColorAllocate($img,0,0,0);
$white = ImageColorAllocate($img,255,255,255);
ImageFilledRectangle($img,0,0,$imgW,$imgH,$white);
$font = 2;
$txt = "Hello, dude!";
ImageString($img,$font,100,100,$txt,$black);
ImageJPEG($img);
ImageDestroy($img);
Expected result:
----------------
If would like to reuse a same code inside function.phtml in all my dinamic charts.
Actual result:
--------------
It isn't working. Only works when I exclude the include.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 19:00:02 2025 UTC |
In response to derek, i have tried using include or require and they both keep breaking my page and it says "The image cannot be displayed because it contains errors." Is there anyway to use include? Here is my code <?php header("Content-type: image/jpg"); include "psnvars.php"; $string = "email@example.com"; $font = 4; $width = ImageFontWidth($font) * strlen($string); $height = ImageFontHeight($font); $im = @imagecreatetruecolor ($width,$height); $background_color = imagecolorallocate ($im, 255, 255, 255); $text_color = imagecolorallocate ($im, 255, 255, 255); imagestring ($im, $font, 0, 0, $string, $text_color); imagejpeg ($im); ?> If i remove include "psnvars.php"; it starts working again