如何编写PHP代码来随机获取一种颜色?
- 内容介绍
- 文章标签
- 相关推荐
本文共计60个文字,预计阅读时间需要1分钟。
phpfunction randColor() { $letters='1234567890ABCDEF'; $color=''; for ($i=0; $i <6; $i++) { $pos=rand(0, 15); $color .=$letters{$pos}; } return $color;}
<?php function randColor(){ $letters = "1234567890ABCDEF"; for($i=1;$i<6;$i++){ $pos = rand(0,16); $str .= $string{$pos}; } return "#".$str; } echo '<span style="color:'.randColor().'">Random Color Text</span>'; ?>
本文共计60个文字,预计阅读时间需要1分钟。
phpfunction randColor() { $letters='1234567890ABCDEF'; $color=''; for ($i=0; $i <6; $i++) { $pos=rand(0, 15); $color .=$letters{$pos}; } return $color;}
<?php function randColor(){ $letters = "1234567890ABCDEF"; for($i=1;$i<6;$i++){ $pos = rand(0,16); $str .= $string{$pos}; } return "#".$str; } echo '<span style="color:'.randColor().'">Random Color Text</span>'; ?>

