Hi
I am trying to make an php script that would make me an nice animated GIF image, with variable texts scrolling all over the image and random photos on background each time the script is executed.
The problem is that there is absolutely no output from PHP when the generated GIF size is over ~500KB. This only happens on my localhost (apache 2.2.8/WINDOWS 2000 SP4 and PHP 5.2.5). On an free webhosting service i tried, the script works perfectly (but it is too slow for me to develop the application, i prefer localhost).
I am researching this issue for over two days now and have pinned-out the problem and made an simple test script that demonstrates the problem on my localhost:
PHP Code:
<?
$i=0;
$x=array();
header("Content-type:text/plain");
while($i<4000)
{
array_push($x,"ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD\n");
$i++;
}
$i=0;
$test=null;
while($i<4000)
{
$test.=$x[$i];
$i++;
}
echo("YOU WILL SEE NOTHING IF LEN IS ABOVE ~500000 BYTES!!\n\n");
echo(substr($test,0,((is_numeric($_GET['len']) && $_GET['len']>0)?$_GET['len']:strlen($test))));
echo("\n\nYOU WILL SEE NOTHING IF LEN IS ABOVE ~500000 BYTES!!");
?>
the method of building my gif animation is the very same as in the sample script. First, a image resource is allocated. Each frame is drawn on this resource in a loop, with every frame data stored into an ARRAY by the means of ob_start and imagegif. Then the animated gif is constructed step-by-step from separate gif frames and its data are held in a string variable $gifdata. Everything is fine when i try to output like this:
PHP Code:
echo(substr($gifdata,0,500));
or like this
PHP Code:
echo(substr($gifdata,0,500000));
but if i pass certain value here, the script wont return absolutely nothing.
....so, if generated gif is bigger than this certain value, this will fail:
PHP Code:
echo($gifdata);
bringing down the WHOLE script, it does not matter if there are echoes before or after this line, simply said if $gifdata is large and the php program contains a line to print $gifdata out, or to var_dump it or anything like that, the while php program wont return nothing.
Error reporting in php.ini on my localhost is set to E_ALL and memory limit for script is 128MB.
Here is the script running on my computer:
http://78.98.181.169/test/test2.php?len=ENTER-NUMBER
for comparison, here is the exact same script running on the free webhosting server and WORKING:
http://goosemaster.ic.cz/test/test2....n=ENTER-NUMBER
Maybe just some apache/php misconfiguration, i am really desperate with this one. Any help would be very appreciated.
...and just for fun the animated gif
working (notice the image size is only 589 kb, so $gifdata is also only 589kb, thats the only thing print out) and
not working (on localhost)