The example in this paper describes how PHP dynamically generates random images of a specified size. Share to everyone for your reference, as follows:
<?php$image_width = +, $image _height = +, $image _str = ", if (Isset ($_get[' W '])) {$image _width = intval ($_get[' W ']) ;} if (Isset ($_get[' h '))) {$image _height = intval ($_get[' h ']);} if (Isset ($_get[' s ')) {$image _str = $_get[' s '];} $img = Imagecreate ($image _width, $image _height); $color = Imagecolorallocate ($img, Mt_rand (157,255), Mt_rand (157,255), Mt_rand (157,255)) Imagefilledrectangle ($img, 0, $image _height, $image _width, 0, $color); $step = Mt_rand ($start) = Mt_rand (0, $step); $color = Imagecolorallocate ($img, Mt_rand (200,255), Mt_rand (200,255), Mt_rand (200,255)); Imagesetthickness ($img, Mt_rand (3)), if ($image _height > $image _width) {for ($i = $start; $i < $image _height * 2; $i + = $step) {imageline ($img, 0, $i, $i, 0, $color); }}else{for ($i = $start; $i < $image _width * 2; $i + = $step) {imageline ($img, $i, 0, 0, $i, $color); }}if ($image _str! = ") {$black = imagecolorallocate ($img, 0, 0, 0); Imagestring ($img, 5, 5, $image _str, $black);} Header (' Content-tyPe:image/png '); Imagepng ($img); Imagedestroy ($img);
More readers interested in PHP related content can view this site topic: "PHP graphics and picture Operation skills Summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", "PHP date and Time usage summary", " PHP Primer for object-oriented programming, PHP string Usage Summary, Introduction to PHP+MYSQL database operations, and PHP common database operations Tips Summary
I hope this article is helpful to you in PHP programming.
The above describes the PHP dynamic generation of random images of the size of the method, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.