Posted in PHP onJuly 24, 2017
本文实例讲述了PHP十六进制颜色随机生成器功能。分享给大家供大家参考,具体如下:
<?php function randomColor() { $str = '#'; for($i = 0 ; $i < 6 ; $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; ?>
运行结果:#8ABED4
PHP十六进制颜色随机生成器功能示例
- Author -
3wlog声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@