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
Tell me how to find the length of a string?
How do I start a php session?
Can I learn laravel without php?
Explain the changes in php versions?
Is php a float?
What is php limit?
How many ways to include array elements in double-quoted strings using php?
What is a collection in php?
Is php open source?
How many types of session are there?
What is the current stable version of php?
Why do you need to filter out empty files?
What is the meaning of symbol '$' in jquery?
Is it possible to remove the html tags from data?
What is session in PHP. How to remove data from a session?