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
How long does a php session last for?
Inside a php function, what param needs to be set in order to access a global variable?
What is the method to register a variable into a session?
What are examples of independent and dependent variables?
Explain me soundex() and metaphone()?
What is an abstract class in php?
What are the four scalar types of php?
What are helpers in php?
What are computer variables?
Which of the delimiter is ASP style?
What is the use of trim function in php?
Why php script is not running in browser?
How can we destroy the cookie in php?
Tell me what the difference between the 'bitwise and' operator and the 'logical and' operator?
What is x+ mode in fopen() used for?