title: PHP Image colour gradient is not displayed correctly
body: <p>I am currently programming a background-image using PHP with a color gradient for all browsers that do not support CSS3. I have got the following code:</p>
  <pre><code>&lt;?php
  header(&quot;Content-Type: image/png&quot;);
  $from=array(&quot;R&quot;=&gt;255, &quot;G&quot;=&gt;255, &quot;B&quot;=&gt;255);
  $to=array(&quot;R&quot;=&gt;170, &quot;G&quot;=&gt;221, &quot;B&quot;=&gt;255);
  
  $width=500;
  $height=1000;
  $image=imagecreate($width, $height);
  for($y=0; $y &lt; $height; $y++)
  {
      imageline($image, 0, $y, $width, $y, imagecolorallocate($image, $from[&quot;R&quot;]-(($from[&quot;R&quot;]-$to[&quot;R&quot;])/$height)*$y, $from[&quot;G&quot;]-(($from[&quot;G&quot;]-$to[&quot;G&quot;])/$height)*$y, $from[&quot;B&quot;]-(($from[&quot;B&quot;]-$to[&quot;B&quot;])/$height)*$y));
  }
  imagepng($image);
  ?&gt;
  </code></pre>
  <p>It seems to be so simple but I really do not know why the image is not displayed correctly. It is shown as you can see below but the gradient should be 1000px high.
  <img src="https://i.stack.imgur.com/7osyt.png" alt="The gradient that is displayed" /></p>