Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is substr() in php? And how it is used?

1025


Can I learn laravel without php?

1010


How is it possible to set an infinite execution time for php script?

954


What is difference between array_merge and array_combine in php?

1017


How to download file in php?

942


Write a program to display a table of any given number?

919


How to include a file to a PHP page?

1034


Tell me how can we connect to a mysql database from a php script?

946


How to select a database in php?

1057


What is the meaning of a final class and a final method?

1081


What is $_ server request_method == post?

1052


What is data type in php?

1027


What is the role of php?

933


How you can update memcached when you make changes to php?

1059


Suppose the variable $var1 is set to 10 and the $var2 is set to the character var1, what's the value of $$var2?

936