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 substr() in php? And how it is used?
Can I learn laravel without php?
How is it possible to set an infinite execution time for php script?
What is difference between array_merge and array_combine in php?
How to download file in php?
Write a program to display a table of any given number?
How to include a file to a PHP page?
Tell me how can we connect to a mysql database from a php script?
How to select a database in php?
What is the meaning of a final class and a final method?
What is $_ server request_method == post?
What is data type in php?
What is the role of php?
How you can update memcached when you make changes to php?
Suppose the variable $var1 is set to 10 and the $var2 is set to the character var1, what's the value of $$var2?