Home > Backend Development > PHP Tutorial > 基于PHP的色彩生成器

基于PHP的色彩生成器

WBOY
Release: 2016-06-13 12:13:05
Original
876 people have browsed it

基于PHP的颜色生成器


 function randomColor()
 { 
    $str = '#'; 
    for($i = 0 ; $i     { 
        $randNum = rand(0 , 15); 
        switch ($randNum) 
        { 
            case 10: $randNum = 'A'; break; 
            case 11: $randNum = 'B'; break; 
            case 12: $randNum = 'C'; break; 
            case 13: $randNum = 'D'; break; 
            case 14: $randNum = 'E'; break; 
            case 15: $randNum = 'F'; break; 
        } 


        $str .= $randNum; 
    } 
    return $str; 

     $color = randomColor();
     echo $color;
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template