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 difference between strstr() and stristr()?

995


Suppose your zend engine supports the mode Then how can you configure your php zend engine to support Mode ?

944


what is CURL?

982


Define urlencode() and urldecode() used in php?

1144


What are the advantages of object-oriented programming in php?

893


What is php simple definition?

948


What is php beginner?

932


How to increase the maximum execution time of a script in php?

935


What is php key?

912


What are the benefits of composer?

979


What is T_PAAMAYIM_NEKUDOTAYIM?

1152


What is design pattern? Explain all including singleton pattern?

953


What are psrs? Choose 1 and briefly describe it?

1389


Can we use get instead of post?

925


What are the differences between mysqli_connect and mysqli_pconnect?

970