php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39778 NO IMG OUTPUT IF SOME ADDITIONAL SCRIPT BLOCK IS WRITTEN BEFORE THE IMG CODE
Submitted: 2006-12-08 16:28 UTC Modified: 2006-12-08 16:29 UTC
From: linuxtyh at gmail dot com Assigned:
Status: Not a bug Package: *Graphics related
PHP Version: 5.2.0 OS: Windows xp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
6 + 6 = ?
Subscribe to this entry?

 
 [2006-12-08 16:28 UTC] linuxtyh at gmail dot com
Description:
------------
IN MY CODE , there is an empty code block before the real useful code block , the empty code block cause no img output in my server 

Reproduce code:
---------------
<?php
///THIS BLOCK OF CODE CAN CAUSE NO IMG OUTPUT

//  ???????±???һ??
//   created by linuxtyh
//   08.12.2006 6:35:40 PM
//
?>
 <?php
 error_reporting(0);
$width=700;
$height=700;
$image = imagecreate($width, $height);
$bg = imagecolorallocate($image, 200, 200, 200);
$textcolor = imagecolorallocate($image, 0, 0, 255);
$linecolor = imagecolorallocate($image, 20, 100, 200);

 
if(!isset($_GET["function"])||$_GET["function"]=="")
{
      imagestring($image, 5, 0, 0, "no function found.", $textcolor);
      //echo("no func");
}
else
{
    $function= $_GET["function"];
    imagestring($image, 5, 0, 0, "function: y=$function ", $textcolor);
//echo("found func");



$amp=30;   //amplify
   if( isset($_GET["amplify"]))
   {    $amp= $_GET["amplify"];
   }
$dx=0;  //offset
$dy=0;   //
$start=-$width/2;
$end=$width/2;
      $function=str_replace ("x","((\$x)/$amp-$dx)" ,$function);
       $function="\$y=$height/2-$amp*($function+$dy);" ;//+";";
     $x=$start;
     $y;
     
   try{
             eval($function);
       }catch(Exception $error)
       {
           	$y=1e20;
       }
      $oldx=$x;$oldy= $y   ;
   imageline($image,  0 , $height/2,   $width   ,  $height/2 , $linecolor);
      imageline($image,  $width /2 , 0,   $width /2  ,  $height  , $linecolor);
     $ox=$width /2;$oy=$height/2;
     for($i=0;$i<$width/2;$i+=1*$amp)
     {
         imageline($image,  $width /2+$i , $height/2,  $width /2+ $i   ,  $height/2-2 , $linecolor);
         imagestring($image, 1, $width /2+$i , $height/2+2 , ""+$i/$amp , $textcolor );
         imageline($image,  $width /2-$i , $height/2,  $width /2- $i   ,  $height/2-2 , $linecolor);
         imagestring($image, 1, $width /2-$i , $height/2+2 , ""+(-$i)/$amp , $textcolor );
     }
     for($i=$amp;$i<$height/2;$i+=1*$amp)
     {
         imageline($image,  $width /2  , $height/2+$i,  $width /2+ 2   ,  $height/2+$i , $linecolor);
         imagestring($image, 1,$width /2 +4 , $height/2+$i, ""+(-$i)/$amp , $textcolor );
         imageline($image,  $width /2  , $height/2-$i,  $width /2+ 2   ,  $height/2-$i , $linecolor);
         imagestring($image, 1,$width /2 +4 , $height/2-$i, ""+($i)/$amp , $textcolor );
     }

     for($x=$start; $x<=$end; $x++)
    {
              try{
             eval($function);
       }catch(Exception $error)
       {
       $y=1e20;
       }
           imageline($image, $oldx+$width/2 , $oldy, $x+$width/2  , $y , $linecolor);
              $oldx=$x;
              $oldy=$y;
     }
 } 
header("Content-type: image/png");
imagepng($image);
  imagedestroy($image);
?>


Expected result:
----------------
a  math function  image

Actual result:
--------------
no image output  but an image of red cross

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-08 16:29 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 19:01:26 2019 UTC