时间:2019-10-20加入收藏
方法二(取现有数组中颜色代码进行随机):<?php
function randColor(){
$colors = array();
for($i = 0;$i<6;$i++){
$colors[] = dechex(rand(0,15));
}
return implode('',$colors);
}
?>
<?php echo '<span style="color: #'.randColor().'">#'.randColor().'</span>';?>
<?php
function randColor(){
$colors=array('5CB85C','428BCA','FF6600','D9534F','B37333','00ABA9');//随机数组中颜色代码
$show_color = array_rand($colors, 1);
return $colors[$show_color];
}
?>
<?php echo '<span style="color: #'.randColor().'">#'.randColor().'</span>';?>
TGA: php