The example in this article describes how PHP dynamically generates a random picture of a given size. Share to everyone for your reference, specific as follows:
<?php $image _width = 100;
$image _height = 100;
$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 (15, 30);
$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, 10)); 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, 12, 5, 5, $image _str, $black);
Header (' content-type:image/png ');
Imagepng ($IMG);
Imagedestroy ($IMG);
More interested in PHP related content readers can view the site topics: "PHP graphics and pictures Operating skills summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", "PHP date and Time usage summary", " Introduction to PHP object-oriented programming, "PHP string (String) Usage Summary", "Php+mysql Database Operations Introduction Tutorial" and "PHP Common database Operation tips Summary"
I hope this article will help you with the PHP program design.