Created
August 1, 2014 19:37
-
-
Save mansueli/0a4b5ad01e833ff42602 to your computer and use it in GitHub Desktop.
Gist php rand() vs mt_rand()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header("Content-type: image/png"); | |
mt_srand((double)microtime()*1000000); | |
$im = imagecreatetruecolor(300, 300) or die("A biblioteca GD provavelmente nao esta' instalada"); | |
$emBranco = imagecolorallocate($im, 255, 255, 255); | |
for ($y = 0; $y < 300; $y++) { | |
for ($x = 0; $x < 300; $x++) { | |
if (mt_rand(0, 1)) { | |
imagesetpixel($im, $x, $y, $emBranco); | |
} | |
} | |
} | |
imagepng($im); | |
imagedestroy($im); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header("Content-type: image/png"); | |
srand((double)microtime()*1000000); | |
$im = imagecreatetruecolor(300, 300) or die("A biblioteca GD provavelmente nao esta' instalada"); | |
$emBranco = imagecolorallocate($im, 255, 255, 255); | |
for ($y = 0; $y < 300; $y++) { | |
for ($x = 0; $x < 300; $x++) { | |
if (rand(0, 1)) { | |
imagesetpixel($im, $x, $y, $emBranco); | |
} | |
} | |
} | |
imagepng($im); | |
imagedestroy($im); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment