note 106252 added to function.rand
| From: | Anonymous at osu1 dot php dot net | Date: | Fri, 21 Oct 2011 15:02:22 +0000 |
| Subject: | note 106252 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184047@lists.php.net to get a copy of this message | ||
According to what Alex Khimch alex wrote at 19-Mar-2011 09:41 his random based image noise generator
will not be random. There was a simple mistake in variable naming. Correct code would be:
<?php
header("Content-type: image/png");
$img = imagecreatetruecolor(500,500);
$ink = imagecolorallocate($img,255,255,255);
for($i=0;$i<500;$i++)
{
for($j=0;$j<500;$j++)
{
imagesetpixel($img, rand(1,500), rand(1,500), $ink);
}
}
imagepng($img);
imagedestroy($img);
?>
----
Server IP: 195.114.0.19
Probable Submitter: 91.194.188.90
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit -- https://master.php.net/note/edit/106252
Del: integrated -- https://master.php.net/note/delete/106252/integrated
Del: useless -- https://master.php.net/note/delete/106252/useless
Del: bad code -- https://master.php.net/note/delete/106252/bad+code
Del: spam -- https://master.php.net/note/delete/106252/spam
Del: non-english -- https://master.php.net/note/delete/106252/non-english
Del: in docs -- https://master.php.net/note/delete/106252/in+docs
Del: other reasons-- https://master.php.net/note/delete/106252
Reject -- https://master.php.net/note/reject/106252
Search -- https://master.php.net/manage/user-notes.php