This article illustrates a simple way to generate random colors in PHP. Share to everyone for your reference, specific as follows:
<?php
//First method:
$rand = Array (' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' A ', ' B ', ' C ', ' d ', ' e ', ' f ';
$color = ' # '. $rand [Rand (0,15)]. $rand [Rand (0,15)]. $rand [Rand (0,15)]. $rand [Rand (0,15)]. $rand [Rand (0,15)]. $rand [ RAND (0,15)];
echo $color. " <br/> ";
The second method:
printf ("#%06x\n", Mt_rand (0, 0xFFFFFF));
>
The results of the operation are as follows:
About color value conversion and acquisition can also refer to the site online tools:
RGB Color Coding Generator
Online Web Color tool
RGB Color Query Matrix _ color code Table _ color of the English name Daquan
For more information about PHP interested readers can view the site topics: "PHP array" operation Skills Encyclopedia, "PHP Mathematical Calculation Skills Summary", "PHP graphics and pictures Operating skills summary", "PHP operation Office Document Skills Summary (including Word,excel, Access,ppt), "The PHP date and time usage summary", "PHP object-oriented Programming Introduction Tutorial", "PHP string (String) Usage Summary", "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation skill Summary"
I hope this article will help you with the PHP program design.