how to change the div background color on every
refresh..guys can u help me out.
Answer Posted / kapil dhiman
<?php
// Class
class ChangeDivColor{
public function __construct(){
$value= array("#000000","#CC0000","#009900","#6600CC","#FFFF00");
$rand_keys=array_rand($value,2);
echo '<div style="height:200px; width:200px; float:left; background:'.$value[$rand_keys[0]].';"></div>';
}
}
$obj= new ChangeDivColor()
// inline coding
$value= array("#000000","#CC0000","#009900","#6600CC","#FFFF00");
$rand_keys=array_rand($value,2);
?>
<div style="height:200px; width:200px; float:left; background:<?=$value[$rand_keys[0]]?>;"></div>
| Is This Answer Correct ? | 5 Yes | 2 No |
Post New Answer View All Answers
What is difference between strstr() and stristr()?
Suppose your zend engine supports the mode Then how can you configure your php zend engine to support Mode ?
what is CURL?
Define urlencode() and urldecode() used in php?
What are the advantages of object-oriented programming in php?
What is php simple definition?
What is php beginner?
How to increase the maximum execution time of a script in php?
What is php key?
What are the benefits of composer?
What is T_PAAMAYIM_NEKUDOTAYIM?
What is design pattern? Explain all including singleton pattern?
What are psrs? Choose 1 and briefly describe it?
Can we use get instead of post?
What are the differences between mysqli_connect and mysqli_pconnect?