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
Is php easier than javascript?
Why do we use hooks?
What type of comments are supported by PHP.
How to check your php installation?
Does php need apache?
Are php short tags acceptable to use?
What difference between require() and require_once()?
What are the advantages of php mysql?
Where to put php files in apache server?
What is the use of token in php?
How to calculate the length of a string?
What is variable function php?
How to get ip address of clients machine?
Write a program in php to check whether a number is prime or not?
Explain the difference between static and dynamic websites?